You can use android:layout_weight
attribute.
Accept the answer if it helped you. :)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical" >
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="New Button" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="New Button" />
</LinearLayout>
</LinearLayout>
** To get the message on click of item in ListView **
listViewItems.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
String str = adapterView.getItemAtPosition(arg2).toString();
Toast.makeText(getApplicationContext(), "You clicked "+ str, 100).show();
}
}
Instead of adapterview, you can use
String str = foodList.get(arg2).getItemName().toString() + " " +foodList.get(arg2).getItemIdInt();