public class TestFragment extends Fragment {
public ImageButton Next;
public View onCreateView(
@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main_tab, container, false);
View root = null;
switch (getArguments().getInt(ARG_SECTION_NUMBER)) {
case 1:
root = inflater.inflate(R.layout.fragment_main_tab, container, false);
break;
case 2:
root = inflater.inflate(R.layout.fragment_team_screen_, container, false);
break;
}
Next = (ImageButton) rootView.findViewById(R.id.btn_expand);
Next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
updatedetails();
}
});
return rootView;
}
public void updatedetails() {
Intent intent = new Intent(getActivity(), Enquiery_followup.class);
startActivity(intent);
}
}
Переставьте код следующим образом.И убедитесь, что оба xml-файла содержат ImageButton с идентификатором - btn_expand
Проблема с вашим кодом заключалась в том, что onClickListener
был до установки view
.