使用静态textView创建列表

时间:2013-11-15 12:19:10

标签: android listview adapter

我需要你的帮助。我的问题是我正在尝试创建一个具有静态textView的布局,并在底部创建一个带有适配器的List。我不知道该怎么做。布局给我看的是我想要的东西:

  

NameOfPerson //静态文本

  • EXM1
  • EXM2
  • Exm3

问题是显示带有静态文本的列表,和/或用列表显示静态文本。我该怎么办?我必须使用片段吗?

谢谢,

3 个答案:

答案 0 :(得分:1)

该解决方案有什么问题?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView" />

    <ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </ListView>

</LinearLayout>

答案 1 :(得分:0)

试试这段代码:

View footerView = ((LayoutInflater) ActivityContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer_layout, null, false);
ListView.addFooterView(footerView);

答案 2 :(得分:0)

请参阅ListView.html.addHeaderView

按照惯例执行ListView,并使用addHeaderView添加额外视图。请务必在addHeaderView之前拨打setAdapter,否则无效。

相关问题