每行具有不同布局膨胀的列表视图 [英] Listview with different layout inflation for each row

查看:29
本文介绍了每行具有不同布局膨胀的列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对在 Android 中设计 UI 还很陌生(而且对 Android 开发也很陌生).我目前正在开发一个 Android 应用程序,它看起来很像 Google+ 的所有圈子"页面和 Facebook 的用户主页,您可以在其中查看朋友分享的内容.

I'm fairly new to designing UIs in Android (And fairly new to Android development as well). I'm currently developing an Android application that looks a lot like Google+'s "All Circles" page, and Facebook's user home, where you get to see contents shared by your friends.

为了让事情更清楚,请看以下来自 Google+ 的 Android 应用程序的屏幕截图:

To make things clearer, please take a look at the following screenshot that's taken from Google+'s Android application:

如您所见,Paul Harper 的帖子在一个小框架中,而Android 和我"的帖子在另一个中.向下滚动的次数越多,您看到的共享内容就越多,每个内容都在自己的框架"中.

As you can see, Paul Harper's post is in a little Frame, and "Android and me"'s post is in another. And the more you scroll downwards, the more shared stuff you'll see, each in its own "Frame".

我真的不知道如何实现这个结果(我确定它涉及到 ListView 组件),所以谁能告诉我我应该使用哪些 UI 组件来实现它?

I'm really not sure how to achieve this result(I'm sure that it involves a ListView component), so could anyone please tell me about the UI components that I should be using to do it?

非常感谢.

推荐答案

您应该看看链接中的视频.

You should have a look at the video in the link.

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 == TYPE_ITEM1) {
                 //infalte layout of type1
      }
    if (type == TYPE_ITEM2) {
                 //infalte layout of type2
    }  else {
                 //infalte layout of normaltype
 }
} 

这篇关于每行具有不同布局膨胀的列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆