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

posted @ 2019-12-05 18:46  咫尺灵犀  阅读(1395)  评论(0编辑  收藏  举报