I was wrong.
So after three or four days of searching, attempting, failing... (Yeah I know I'm slow) I magically discovered four magical lines of text that allow me to make all my wildest dreams come true. At least for now.
So here's how I did it:
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_height="fill_parent"
android:layout_width="fill_parent" android:id="@+id/LinearLayout_listview">
<TextView android:layout_height="wrap_content"
android:layout_width="fill_parent" android:text="title" android:id="@+id/TextView_Title"
android:padding="5px" android:textSize="20px" />
<ListView android:layout_height="wrap_content" android:id="@android:id/list"
android:layout_width="fill_parent" android:layout_weight="1" />
<FrameLayout android:layout_height="wrap_content"
android:id="@+id/FrameLayout_listview" android:layout_width="fill_parent" />
</LinearLayout>
extrabuttonlayout.xml
<LinearLayout android:layout_height="wrap_content" android:layout_width="fill_parent"
android:gravity="center" android:id="@+id/LinearLayout_er">
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Search"
android:minWidth="100px" android:id="@+id/btnEmergencyResponse_Search"></Button>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Exit"
android:minWidth="100px" android:id="@+id/btnEmergencyResponse_Exit"></Button>
</LinearLayout>
and finally the oh so dynamic MainActivity.java (I only included the part where I dynamically add a view, for info on how to dynamically populate a listview, or handle click evens, see my other entries.) Basically here we are setting our layout to be a "view" and then adding the view to the main layout. Silly me, I already thought it was a view...
public class MainActivity extends ListActivity {
LayoutInflater linflater;
LinearLayout llList;
LinearLayout llER;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//trying to add view to listview.xml
llList = (LinearLayout) findViewById(R.id.LinearLayout_listview);
linflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View myView = linflater.inflate(R.layout.extrabuttonlayout, null);
llList.addView(myView);
}
}
No comments:
Post a Comment