我正在设置我的布局,例如contacts应用,这是我的应用布局:
我有2个列表视图,一个用于电话,另一个用于电子邮件,我想为每个人设置标题,就像联系人应用一样。有人可以指导我如何做到这一点?
xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello, World"
style="?android:attr/listSeparatorTextViewStyle"/>
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
>
</ListView>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello, Universe"
android:layout_above="@+id/listView2"
style="?android:attr/listSeparatorTextViewStyle"/>
<ListView
android:id="@+id/listView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/listView1"
>
</ListView>
</RelativeLayout>
</LinearLayout>
活动:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_contato_details);
Bundle parametros = getIntent().getExtras();
tele = (ArrayList<ContatosTelefoneModel>) parametros.get("tel");
email = (ArrayList<ContatosEmailModel>) parametros.get("email");
ListView b = (ListView) findViewById(R.id.listView1);
b.setHeaderDividersEnabled(true);
b.setAdapter(new TelefoneListAdapter(this, tele));
ListView e = (ListView) findViewById(R.id.listView2);
e.setHeaderDividersEnabled(true);
e.setAdapter(new EmailListAdapter(this, email));
}
答案 0 :(得分:2)
当您提供图片时,他们使用了StickyListHeaders
,您可以在这里找到
https://github.com/emilsjolander/StickyListHeaders
您看到的图片顶部是您可以在此处找到的标签
https://www.dropbox.com/s/cu6kauu6vhsss45/tabcarousellib.rar