-1

I need to create a feed screen like facebook application where I will fetch data from api and each row has different size of images and text. I know ScrollView is for both homogeneous and heterogeneous collection and listView is for only homogeneous collection but can I use listview for heterogeneous collections for feed. ?

Jun Aid
  • 464
  • 7
  • 16
Waleed Arshad
  • 1,081
  • 3
  • 12
  • 24

2 Answers2

2

You can try something like this:

private List mList = new ArrayList();

mList.add("String");
mList.add('A');
mList.add(true);

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ......
    ......
    ......
    if(mList.get(position) instanceof String){

    }else if(mList.get(position) instanceof Character){

    }else if(mList.get(position) instanceof Boolean){

    }
}

@Override
public int getItemViewType(int position) {
    if(mList.get(position) instanceof String){
        return 0;
    }else if(mList.get(position) instanceof Character){
        return 1;
    }else if(mList.get(position) instanceof Boolean){
        return 2;
    }
    return 0;
}

Or normalize them into a common Class.

Archie.bpgc
  • 23,812
  • 38
  • 150
  • 226
0

Yes it is possible. React native handle is very efficiently. i have left no option except to implement and see if it works and yes it is working awesomely. Also this post help me a lots to go through Recycling Rows For High Performance React Native List Views Thanks

Waleed Arshad
  • 1,081
  • 3
  • 12
  • 24