Android - how to add an item click method to an ArrayAdapter

前端 未结 3 1248
Happy的楠姐
Happy的楠姐 2021-01-12 03:11

I have a simple ArrayAdapter. I want to set up a listener for every row click of my list such that a new Activity opens. How would I do that? My ArrayAdapter code -

3条回答
  •  北海茫月
    2021-01-12 03:52

    Once you have set your adapter using:

    mListView.setAdapter(myCountryListAdapter); 
    

    Then you can setup a click listener for the listview:

    mListView.setOnParentClickListener(new  OnClickListener() {         
        public void onClick(View view,) {
                ///do what you want the click to do
        }       
        });
    

提交回复
热议问题