How can I set onClickListener on ArrayAdapter?

后端 未结 4 1509
半阙折子戏
半阙折子戏 2020-12-03 00:23

I\'m making class like as below

// All necessary imports are here

public class More extends Activity {

    String[] MoreItems = { \"Transfers\", \"Budgets\         


        
4条回答
  •  独厮守ぢ
    2020-12-03 01:12

    Your "More" class has to extend ListActivity instead of Activity, then you can override onListItemClick

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        //do something here using the position in the arrya
    }
    

    Edit: Forgot to say, in your layout your ListView has to be called: android:id="@android:id/list"

提交回复
热议问题