How to create a clickable Listview and go to new page

后端 未结 2 1679
面向向阳花
面向向阳花 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);
    
              }
            });
    
    0 讨论(0)
  • 2021-01-03 17:29

    use Listview item click listener

    getListView().setOnItemClickListener(new OnItemClickListener() {    
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
            // your code is here on item click
        }
    });
    
    0 讨论(0)
提交回复
热议问题