Agustín Agustín - 1 year ago 85
Android Question

Android ListView with onClick items

I'm a new programmer and new in Android. I'm using this example and it works great.

Now I want to make the items (Dell, Samsung Galaxy S3, etc) to call a function to open a new activity with different information each.

For example:

If I touch Dell, a new Activity has to show up showing me information about Dell. If I touch Samsung, the same thing.

I Googled but couldn't find anything helpfull, any hint? I think this is basic, but I'm new so I don't really know where to start

Answer Source

In your activity, where you defined your listview

you write

listview.setOnItemClickListener(new OnItemClickListener(){   
    public void onItemClick(AdapterView<?>adapter,View v, int position){
        ItemClicked item = adapter.getItemAtPosition(position);

        Intent intent = new Intent(Activity.this,destinationActivity.class);
        //based on item add info to intent

in your adapter's getItem you write

public ItemClicked getItem(int position){
    return items.get(position);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download