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. ?
Asked
Active
Viewed 422 times
-1

Jun Aid
- 464
- 7
- 16

Waleed Arshad
- 1,081
- 3
- 12
- 24
-
have you tried custom adapter? – Samrat Das Aug 01 '16 at 09:20
-
Well i am using react native and custom adapter does not exist in react-native. my question is that is it possible? if it is then react-native definitely support for this. – Waleed Arshad Aug 01 '16 at 09:21
-
@SamratDas it is possible by using listview. – Waleed Arshad Aug 01 '16 at 10:11
-
1It's almost like a top google hit. Word for word. https://github.com/codepath/android_guides/wiki/Implementing-a-Heterogenous-ListView – OneCricketeer Aug 02 '16 at 07:14
-
@waleedarshadmuhammadarshad you can easily do this with recyclerView with different type https://guides.codepath.com/android/Heterogenous-Layouts-inside-RecyclerView – Amir Aug 02 '16 at 12:07
2 Answers
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