Listview with different layout inflation for each row

I am new to Android user interface development (and quite new to Android development). I am currently developing an Android application that is very similar to the All Circles Google+ page and the Facebook homepage, where you can see the content available to your friends.

To make things clearer, check out the following screenshot taken from the Google+ Android app:

enter image description here

As you can see, Paul Harper’s message is in a small frame, and the “Android and Me” post is in a different frame. And the more you scroll down, the more general material you will see, each in its own “Frame”.

, ( , ListView), - , ?

.

+5
2

.

http://www.youtube.com/watch?v=wDBM6wVEO70

private static final int TYPE_ITEM1 = 0;
private static final int TYPE_ITEM2 = 1;
private static final int TYPE_ITEM3 = 2;    

int;

@Override
public int getItemViewType(int position) {

    if (position== 0){
        type = TYPE_ITEM1;
    } else if  (position == 1){
        type = TYPE_ITEM2;
    }
    return type;
}


@Override  
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
LayoutInflater inflater = null;
int type = getItemViewType(position);
   if (row  == null) {
    if (type == FIRST_TYPE) {
                 //infalte layout of type1
      }
    if (type == FIRST_TYPE) {
                 //infalte layout of type2
    }  else {
                 //infalte layout of normaltype
 }
} 
+7

. , , "ListView", "ListFragment", "ListActivity". () , , . ( ) , , . () "ArrayAdapter", "SimpleCursorAdapter".

Google " Android" " Android".

, Sebastian

+1

All Articles