How can I set onClickListener on ArrayAdapter?

后端 未结 4 1507
半阙折子戏
半阙折子戏 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

    There are two option to handle click event for each row.

    1) If your class extends ListActivity, you can override following method.

    @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 array
    }
    

    2) Handle click event of row in getView() method

    row.setOnClickListener(new OnClickListener() {
    
        @Override
        public void onClick(View v) {
    
        }
    });
    

提交回复
热议问题