Search code examples
javaandroidlistviewandroid-tabs

Android dynamic list view to different screens?


List elements and tabbed-panel contents are populating from json file. When I click A element in listview1 it has to go to tabbeddpanel(above).

When I click B element in listview1 it has to go to listview2 screen and when I click B1 element in listview2 it has to go to tabbedpanel(below).

Help me in doing this

enter image description here


Solution

  • Modify the data set passed to your listview1 so that you can add a tag here.

    For example, the data set you're passing in your listview1 is an ArrayList of tis object.

    public class myData {
        private String content;
        private int tag;    // Add a tag attribute to handle them differently in the list.
    }
    
    // Here's the list passed to your `listview1` 
    private ArrayList<myData> myDataList = new ArrayList<myData>();
    

    Now inside your bindView function check for the tag of the object of that position and handle the action differently like this.

    if(myDataList.get(position).getTag() == 0) {
        // Do this
    } else {
        // Do something else
    }