列表视图不同的布局通胀的每一行 [英] Listview with different layout inflation for each row
问题描述
我是相当新的在Android的用户界面设计(和相当新的Android开发以及)。我目前正在开发一个Android应用程序,它看起来很像谷歌+的各界页面,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.
要更清楚,请看看这是采取从谷歌+的Android应用程序下面的截图:
To make things clearer, please take a look at the following screenshot that's taken from Google+'s Android application:
正如你所看到的,保罗哈珀的职位是在一个小框,而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;
整型;
@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
}
}
这篇关于列表视图不同的布局通胀的每一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!