Intent from Fragment to Activity

后端 未结 11 1484
再見小時候
再見小時候 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-03 23:51

    public class OneWayFragment extends Fragment {
    
        ImageView img_search;
    
    
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
    
    
            View view = inflater.inflate(R.layout.one_way_fragment, container, false);
            img_search = (ImageView) view.findViewById(R.id.search);
    
    
            img_search.setOnClickListener(new View.OnClickListener() {
                @Override`enter code here`
                public void onClick(View v) {
                    Intent displayFlights = new Intent(getActivity(), SelectFlight.class);
                    startActivity(displayFlights);
                }
            });
    

提交回复
热议问题