Is it possible to have components other than List in ListActivity
By using the following code.
BuyActivity.java
public class BuyActivity extends ListActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.transaction_list_view);
OrderAdapter orderAdapter = new OrderAdapter(this,
R.layout.custom_row_view, new ArrayList<Object>());
setListAdapter(orderAdapter);
orderAdapter.add(new Object());
orderAdapter.add(new Object());
}
}
transaction_list_view.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:la开发者_Python百科yout_width="match_parent"
android:layout_height="match_parent">
<ListView android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:drawSelectorOnTop="false">
</ListView>
<TextView android:id="@id/android:empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="No data"
/>
</LinearLayout>
custom_row_view.xml
Please refer to custom_row_view.xml
I was able to get the following outcome.
Besides list, I would also like to have a static label at the bottom of ListActivity.
I try
transaction_list_view.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">
<ListView android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:drawSelectorOnTop="false">
</ListView>
<TextView android:id="@id/android:empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="No data"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="THIS IS TOTAL STATIC LABEL"
/>
</LinearLayout>
But I am getting
What my expectation is
Is there anything I had missed out?
You have indicated that your ListView
is supposed to fill_parent
in the vertical orientation, leaving no room for your other widgets. Your weight is being ignored. You probably want to have your android:layout_height
be 0dip
instead.
Try setting the height of the static textview to wrap_content.
Well you could try Relative Layout to just set the static label anchored to the bottom of the screen. If that's not what you meant, I would try to help you further on. Good luck
精彩评论