问答详情
源自:2-3 ChooseMessageActivity

空指针异常

java.lang.NullPointerException

            at com.example.administrator.festivalsms_imooc.fragment.FragmentCatory$2.onItemClick(FragmentCatory.java:64)



代码


gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override

            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                Intent intent = new Intent(getActivity(), ChooseMsgActivity.class);

                intent.putExtra(ID_FESTIVAL, adapter.getItem(position).getId());

                startActivity(intent);

            }

        });


提问者:Oscarui 2015-10-18 16:21

个回答

  • 只呆不萌
    2015-11-25 18:16:27


    gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

                @Override

                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                    Intent intent = new Intent(getActivity(), ChooseMsgActivity.class);

                    intent.putExtra(ID_FESTIVAL, adapter.getItem(position).getId());

                    startActivity(intent);

                }

            });