I got a xml layout file like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/tabBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#474747"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/BtnSlide"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@null"
android:src="@drawable/lin" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="SteriaFIT Mobile"
android:gravity="center"
android:paddingLeft="12dp"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<RelativeLayout
android:background="#41413F"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<LinearLayout
android:id="@+id/some_layout_item"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</LinearLayout>
<View
android:layout_below="@id/some_layout_item"
android:layout_width="fill_parent"
android:layout_height="5dip"
android:background="@drawable/drop_shadow">
</View>
<ListView android:id="@+id/list" android:layout_width="match_parent" android:layout_height="wrap_content"
android:background="#FFFFFF" android:cacheColorHint="#FFFFFF">
</ListView>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="To Next Activity" />
I only want to get the tabBar layout from this file into another xml layout file, i do this by including after @+id this way:
<include android:id="@+id/tabBar" layout="@layout/horz_scroll_app" />
but it seems to me that this line of code will include the whole layout file?
EDIT
should mention that this method will also give me the Button with the id button1
EDIT 2
Ok, so after putting the tabBar inside a new layout file like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#474747"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/BtnSlide"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@null"
android:src="@drawable/lin" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="SteriaFIT Mobile"
android:gravity="center"
android:paddingLeft="12dp"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
and included this to my orginal xml layout like this:
<include layout="@layout/tab_bar" android:id="@+id/tabBar" />
it seems to me that I cant register any OnClickListener to my ImageButton inside my tabBar layout. What I tried to do:
View app = inflater.inflate(R.layout.tab_bar, null);
ViewGroup tabBar = (ViewGroup) app.findViewById(R.id.tabBar);
btnSlide = (ImageButton) tabBar.findViewById(R.id.BtnSlide);
btnSlide.setOnClickListener(new ClickListenerForScrolling(scrollView, menu));
Can anybody give me a hint=
Include is used to include the whole xml file into the current layout. If you only want tabBar path then put them into a separate layout file then include them into the original view as well.
You will access the view normally:
I believe, the whole putting views together part is done when compile. So you treat it as you normally would to a view in xml layout.