Intent from Fragment to Activity

后端 未结 11 1486
再見小時候
再見小時候 2021-02-03 23:22

I was trying to go to another page using button, but it always fail.

Here is my First Class with its XML:

public class Fin         


        
11条回答
  •  滥情空心
    2021-02-04 00:12

    in your receiving intent use as

    Intent intent = getActivity().getIntent();
            ((TextView)view.findViewById(R.id.hello)).setText(intent.getStringExtra("Hello"));
    

    and in your send intent

    Intent intent = new Intent(getActivity(),Main2Activity.class);
            intent.putExtra("Hello","Nisar");
            getActivity().startActivity(intent);
    

    remember both are in fragments

提交回复
热议问题