为了账号安全,请及时绑定邮箱和手机立即绑定

Fragment中点击事件跳转活动报错

Fragment中点击事件跳转活动报错

富国沪深 2018-07-31 11:14:34
本来想实现点击“售后服务”这一块的Linearlayout跳转到Guarantee这个活动当中这一功能public class ThirdFragment extends Fragment implements View.OnClickListener{ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.third_fragment, container, false); LinearLayout guaranteell = (LinearLayout) view.findViewById(R.id.serviceGuaranteeId); guaranteell.setOnClickListener(this); return view; } @Override public void onClick(View view){ MainActivity mainActivity = new MainActivity(); Intent intent = new Intent(mainActivity, Guarantee.class); startActivity(intent); //Toast.makeText(mainActivity, "you clicked this", Toast.LENGTH_SHORT).show(); } }但是报错java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 703 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号