Android: onListItemClick in Activity

前端 未结 8 2019
故里飘歌
故里飘歌 2020-12-28 21:23

Previous time I asked a question here I learned a lot so I guess it\'s worth a shot to try it again.

I am using the lazy list by Fedor from this link: Lazy load of i

8条回答
  •  失恋的感觉
    2020-12-28 21:32

    I am writing my answer as:

    1) the code by @Falmarri needs some update
    2) My suggested edit was totally rejected XD
    3) Stackoverflow is not allowing me to write a comment.

    Here is the code:

    ListView listView = (ListView) findViewById(R.id.my_listview_in_layout);
    listview.setOnItemClickListener(new AdapterView.OnItemClickListener(){
        @Override
        public void onItemClick(AdapterView parent, View view, int position, long id){
            //Do stuff
            //...
        }
    });
    


    Reference: According to android.widget.AdapterView.OnItemClickListener , public method onItemClick() is the method invoked when an item is clicked {instead of unknown protected method onListItemClick() }

提交回复
热议问题