android 点击图片从Fragment跳转到activity
android 点击图片从Fragment跳转到activity
在Fragment里编写
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
homeViewModel =
ViewModelProviders.of(this).get(HomeViewModel.class);
View root = inflater.inflate(R.layout.fragment_home, container, false);
ImageView imgc = root.findViewById(R.id.imageView4);
imgc.setOnClickListener(new MyJump());
return root;
}
private class MyJump implements View.OnClickListener{
@Override
public void onClick(View view){
Intent intent = new Intent();
intent.setClass(getActivity(), Listshow.class);
startActivity(intent);
}
}
Listshow是另一个activity