I'm using ListActivity to set up my listview. What I want to do is I want to display listview in upper portion and a linearlayout at parent bottom.
Since I'm using ListActivity, I'm not laying out any layout file. Still what I managed to do is getting the listview instance but when I'm trying to set it in linearLayout I'm getting an error:
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first
I'm using the following code:
final ListView lv = getListView();
LinearLayout root = new LinearLayout(this);
root.setOrientation(LinearLayout.VERTICAL);
root.setLayoutParams(new LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT));
root.addView(lv);
setContentView(root);
what you got to do is define your custom layout, doesn´t matter if is a ListActivity always that your custom xml layout has one ListView with id: android:id="@android:id/list"
i defined my activity layout like this:
later on my activity create defined the layout above:
that´s all, folks