我有一个自定义ListView 我想在屏幕底部添加一个固定按钮。
我应该如何更改布局?
我的屏幕XML代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".ListAdapter" >
<ImageView
... />
<TextView
... />
</RelativeLayout>
我的自定义arrayAdapter源代码:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.msg_detail_layout, parent, false);
msgBodyCustomer = (TextView) rowView.findViewById(R.id.MsgBodyCustomer);
contactImageCustomer = (ImageView) rowView.findViewById(R.id.PhotoImageCustomer);
if(!smslist.get(position).getType().equals(INBOX)){
msgBodyOwner.setText(smslist.get(position).getBody());
contactImageCustomer .setImageURI((smslist.get(position).getPicture()));
return rowView;
}
}
答案 0 :(得分:0)
编辑:试试这个
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".ListAdapter" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button5"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/listView7"
android:layout_alignRight="@+id/PhotoImageOwner"
android:layout_above="@+id/button5" />
</RelativeLayout>
答案 1 :(得分:0)
或者,您可以为--max-requests
footer
页脚将始终位于底部
代码:
custom listview
请参阅上面的java文件<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="7dip"
android:paddingBottom="7dip"
android:orientation="horizontal"
android:gravity="center">
<ImageView
android:id="@+id/footer_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
/>
<TextView
android:text="@string/footer_text_1"
android:id="@+id/footer_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
,在其中初始化列表视图:
onCreate()
参考信用额度为:this answer