Android - How to create clickable listview?

后端 未结 5 1248
心在旅途
心在旅途 2020-11-28 13:57

I want to make all my list items in the listview open up into a new page, so each listview item opens up onto a new black page that I can use. I don\'t know how to implement

5条回答
  •  旧巷少年郎
    2020-11-28 14:22

    You use the onListItemClick function to set up your Intent that loads the next activity and passes any data across.

    public void onListItemClick(ListView parent, View view, int position, long id)
    {
        Intent intent = new Intent(this, AnotherActivity.class);
        intent.putExtra("position", position);
        startActivity(intent);
    }
    

提交回复
热议问题