Android - How to create clickable listview?

后端 未结 5 1259
心在旅途
心在旅途 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:20

    listView= (ListView) findViewById(R.id.listview);

    • List item

      listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView parent, View view, int position, long id) {
      
              if(position==0){
                  Intent i=new Intent(MainActivity.this,Main3Activity.class);
                  startActivity(i);
              }
          }
      });
      

提交回复
热议问题