Reputation: 29
I am making an app, and I have the following XML file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#f4f4f4" >
<ExpandableListView
android:id="@+id/lvExp"
android:layout_width="match_parent"
android:layout_height="325dp" />
<Button
android:id="@+id/add_claim"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add Claim" />
</LinearLayout>
I made a button called View_list that wants to see only the expandable list view on the entire page. what I did is create a new XML file, and added the follwing include statement:
<include android:id="@+id/lvExp"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
However, I realized that this will now work for two reasons
1 - There is no layout ID
2- I only want the list, not the button and everything else I am going to put in the original layout. What is going to happen is if I add something to the list, I need to be able to view it without the option of adding antthing to it.
My question is therefore this:
How do I find the layout ID and how can I prevent the entire layout from showing, and only show the list. I would really appreciate some advice.
Upvotes: 0
Views: 108
Reputation: 22038
The include should say:
<include layout="@layout/View_list"
android:id="@+id/lvExp"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
This includes the View_list.xml
layout in another layout.
But I dont really understand why you would use an include
here if you don't want to re-use the whole layout, but only the list part of it. include
s exist to easily use layouts in other layouts, if you need just a ListView
, use just a ListView
.
EDIT: I'm not sure anymore if I got your question right, but I'll not delete the answer because you commented on it. If you want to hide the button or other Views on the click of a button, you can set their visibility to gone programmatically.
Upvotes: 1