How to create a clickable Listview and go to new page

后端 未结 2 1678
面向向阳花
面向向阳花 2021-01-03 16:59

I\'m a new programmer in android. I want to create a Clickable Listview. I mean when users clicked on one item it goes to a new page and start a new activity. Please help me

2条回答
  •  攒了一身酷
    2021-01-03 17:23

    ListView lv = getListView();
    
    
            lv.setOnItemClickListener(new OnItemClickListener() {
              public void onItemClick(AdapterView parent, View view,
                  int position, long id) {
                   String selval = ((TextView) view).getText().toString();
    
                  Intent intnt = new Intent(getApplicationContext(), nextactivity.class);
                    intnt.putExtra("selval ", selval);
                  startActivity(i);
    
              }
            });
    

提交回复
热议问题