相对布局的底部我对Android非常新。我正在创建一个包含可点击文本的应用程序。 所有可点击的文本都存在于一个数组中,然后该数组与ListView
关联,并显示在RelativeLayout中。需要一个按钮在Android
代码是 -
this.setListAdapter(new ArrayAdapter<String>(this, R.layout.main, R.id.label, contact_name));
ListView lv = getListView();
主要是相对布局,标签布局中的文本框的id和CONTACT_NAME是去为可点击文本的数组。这一切工作正常。
最后,当数组非常大时,线性布局变得可滚动。
现在我想限制这个列表占用的区域占总屏幕高度的80%或90%,并在底部预留一个按钮,这将打开一个新的页面/视图。在相对布局中包含按钮是为列表中的每个项目添加一个按钮。更改相对布局的高度正在改变列表中每个项目的高度。由此得出结论,数组中的每个项目都与整个相对布局相关联,并且相对布局的数组来显示所有项目。现在,如何通过将相对布局列表限制在顶部屏幕的80%来在底部放置按钮。
这是当前的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"
android:orientation="vertical" >
<Button
android:id="@+id/btn"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="Next"
/>
<ScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/btn">
<TextView
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dip"
android:textSize="16sp"
android:textStyle="bold" >
</TextView>
</ScrollView>
</RelativeLayout>
结束输出为隐藏的实际内容下一个按钮的阵列。
这是我的Java代码
// Make the contact number parameter accessible to member functions of List View
final String[] f_contact_number = contact_number;
// Binding Array to ListAdapter
this.setListAdapter(new ArrayAdapter<String>(this, R.layout.main, R.id.label, contact_name));
ListView lv = getListView();
// listening to single list item on click
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(f_contact_number[position]));
startActivity(intent);
}
});
Contact_number和contact_names两个字符串数组,其上单击CONTACT_NAME
Thanks
你能检查一下代码并告诉我我在做什么错?我尝试了很多,但我得到的输出是不希望的。 – user2550128