-3
public void onListItemClick(ListView l, View v, int position, long id) 
        {

           // Do something when a list item is clicked
            if ( position == 5)
            {
                Intent myIntent = new Intent(Categories.this,Adventure.class);
                startActivity(myIntent);
            }


        }

how do I select a listview item and bring me to a new page?

2 Answers2

-1

You need to set listiemClickListner(); Implement onListItemClick for activity class and then,

 ListView lv = (ListView)findViewById(R.Id.LV);
    lv.setOnListItemclickListner(this);

if you have want, you can set listner for each listviews like this.

lv.setOnItemClickListener(new OnItemClickListener() {

    @Override
public void onItemClick(AdapterView<?> arg0, View arg1,
                    int position, long arg3) {

            }
});
Jithu
  • 1,478
  • 1
  • 13
  • 21
-1
list.setOnItemClickListener(new OnItemClickListener() {

    @Override
public void onItemClick(AdapterView<?> arg0, View arg1,
                    int position, long arg3) {
        if ( position == 5)
        {
            Intent myIntent = new Intent(Categories.this,Adventure.class);
            startActivity(myIntent);
        }
}
});
Zoran
  • 1,484
  • 1
  • 10
  • 13