Android Tab Like Footer

I want to reuse my tabs as a footer for every action in my application.

I am using this code

<TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="wrap_content" > <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_above="@android:id/tabs" /> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" /> </RelativeLayout> </TabHost> 

and I want to add components like ListView, Button, etc. on top of my tabs for each layout. How can i do this?

+4
source share
1 answer

I did something similar by expanding the overall base activity in which I overridden the setContentView method.

 abstract public class BaseActivity extends Activity { @Override public void setContentView(View view) { // get master LayoutInflater inflater = LayoutInflater.from(this); // this is the master view with a container and the footer, you can // as well add the header RelativeLayout rlMasterView = (RelativeLayout) inflater.inflate(R.layout.master, null); rlMasterView.addView(view); super.setContentView(rlMasterView); } } 

SetContentView creates a footer and binds it to the view that I set in each action.

I could just use the include tag in each layout.

 <include src="footer" /> 
+2
source

Source: https://habr.com/ru/post/1388292/


All Articles