[英]cant see my footer with ListActivity
我正在尝试在我的自定义列表中添加页脚,但仍然无法解决。 我的目的只是在列表末尾添加一些按钮。 我尝试了这个:
adapter = new GeneralRssAdapter(this,R.layout.titlesrss, data);
LayoutInflater inflater = getLayoutInflater();
lv.addFooterView( inflater.inflate( R.layout.footer_layout, null ), null, false);
lv.setAdapter(adapter);
但仍然看不到任何页脚。 这是我的xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/linearLa"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/iconremove"
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_margin="5dip"
android:scaleType="centerCrop"
android:src="@drawable/delete"
android:visibility="gone" />
<ImageView
android:id="@+id/iconfav"
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_margin="5dip"
android:scaleType="centerCrop"
android:src="@drawable/rss" />
<TextView
android:id="@+id/textView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal|center"
android:layout_margin="5dip"
android:layout_weight="1"
android:textSize="20dip" />
</LinearLayout>
<ListView android:id="@+id/ListView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
和页脚:
<?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" >
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.20"
android:src="@drawable/tutorialrss"
/>
</LinearLayout>
希望你能帮我:)
尝试这个
adapter = new GeneralRssAdapter(this,R.layout.titlesrss, data);
LayoutInflater mInflater = (LayoutInflater)getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
final View footer = mInflater.inflate(R.layout.footer_layout, null);
choicelist.addFooterView(footer);
choicelist.setAdapter(adapter);
我已经编辑了这个xml
<?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" >
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/tutorialrss"
/>
</LinearLayout>
对我来说,它的工作检查一次。
adapter = new ListAdapter(this, data);
ListView lvMain = (ListView) findViewById(R.id.list);
LayoutInflater mInflater = (LayoutInflater) getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
final View footer = mInflater.inflate(R.layout.footer, null);
lvMain.addFooterView(footer);
lvMain.setAdapter(adapter);
我要做的是在setContentView()
设置页脚/页眉,然后在适配器中使用list
xml。 我通常不喜欢一行答案,但这就是我要做的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.