well we know that people who are building their app on android 4.0 or the latest ones have the special support of the action bar which can be easily adjusted to the top and the bottom of the screen by navigating to the whole app but the developers who are coding for the android 2.2 are either going for the apis like actionbar sherlock but if you dont want to use it then you can simply design the layout of the footer or bottom bar and add it to the bottom of the activity by <include> tag
footer.xml
this is the layout of that bottom bar.
<?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="wrap_content"
android:background="#fff" android:id="@+id/foot">
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:orientation="vertical" android:layout_weight="1" android:gravity="center">
<Button android:text="" android:id="@+id/home"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ic_menu_home" android:onClick="onhome"></Button>
<TextView android:text="Home" android:id="@+id/TextView01"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000"></TextView>
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout02"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:orientation="vertical" android:layout_weight="1" android:gravity="center">
<Button android:text="" android:id="@+id/appointment"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ic_menu_agenda" android:onClick="onapp"></Button>
<TextView android:text="Appointment" android:id="@+id/TextView02"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000"></TextView>
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout03"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:orientation="vertical" android:layout_weight="1" android:gravity="center">
<Button android:text="" android:id="@+id/ques"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ic_menu_help" android:onClick="onques"></Button>
<TextView android:text="QandA" android:id="@+id/TextView03"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000"></TextView>
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout04"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:orientation="vertical" android:layout_weight="1" android:gravity="center">
<Button android:layout_height="wrap_content" android:text=""
android:id="@+id/blog" android:layout_width="wrap_content" android:background="@drawable/blog" android:onClick="onblog"></Button>
<TextView android:text="Blog" android:id="@+id/TextView04"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000"></TextView>
</LinearLayout>
</LinearLayout>
*******************************************************************************
Include usability
add this tag to your activity layout where you want to locate it and my advice it to use relative layout as it is good way to locate at bottom or on top
<include android:id="@+id/foot" layout="@layout/footer"></include>
Now to code for the class which would be extended by all the other classes in which this bar needs to be inserted.
make class for eg. basetabactivity and imply all the functions of bar buttons
public class basetabactivity extends Activity {
Button home, appointment, ques, blog;
applicationob app;
LinearLayout li;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.footer);
app = (applicationob) getApplication();
home = (Button) findViewById(R.id.home);
appointment = (Button) findViewById(R.id.appointment);
ques = (Button) findViewById(R.id.ques);
blog = (Button) findViewById(R.id.blog);
}
public void setcontent(int id) {
li = (LinearLayout) findViewById(R.id.foot);
home = (Button) findViewById(R.id.home);
appointment = (Button) findViewById(R.id.appointment);
ques = (Button) findViewById(R.id.ques);
blog = (Button) findViewById(R.id.blog);
}
public void onhome(View v) {
startActivity(new Intent(this, lawyer.class).addFlags(
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT).addFlags(
Intent.FLAG_ACTIVITY_SINGLE_TOP));
}
public void onapp(View v) {
startActivity(new Intent(this, appointment.class).addFlags(
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT).addFlags(
Intent.FLAG_ACTIVITY_SINGLE_TOP));
}
public void onques(View v) {
startActivity(new Intent(this, Quest.class).addFlags(
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT).addFlags(
Intent.FLAG_ACTIVITY_SINGLE_TOP));
}
public void onblog(View v) {
startActivity(new Intent(this, Blog.class).addFlags(
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT).addFlags(
Intent.FLAG_ACTIVITY_SINGLE_TOP));
}
}
Now if you have to extend this class in which you want the bottom bar to be functioned like if you want abc class to perform that bottom bar then you will simply extend that class
public class abc extends basetabactivity{
oncreate{
setcontentView(R.layout.footer);//include layout of footer first
setcontentView(R.layout.abc);// secondly layout of abc
}
}
Hope this code will help you in developing the bottom bar stuff any queries feel free to drop your comments
have a good programming!!!
footer.xml
this is the layout of that bottom bar.
<?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="wrap_content"
android:background="#fff" android:id="@+id/foot">
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:orientation="vertical" android:layout_weight="1" android:gravity="center">
<Button android:text="" android:id="@+id/home"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ic_menu_home" android:onClick="onhome"></Button>
<TextView android:text="Home" android:id="@+id/TextView01"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000"></TextView>
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout02"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:orientation="vertical" android:layout_weight="1" android:gravity="center">
<Button android:text="" android:id="@+id/appointment"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ic_menu_agenda" android:onClick="onapp"></Button>
<TextView android:text="Appointment" android:id="@+id/TextView02"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000"></TextView>
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout03"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:orientation="vertical" android:layout_weight="1" android:gravity="center">
<Button android:text="" android:id="@+id/ques"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ic_menu_help" android:onClick="onques"></Button>
<TextView android:text="QandA" android:id="@+id/TextView03"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000"></TextView>
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout04"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:orientation="vertical" android:layout_weight="1" android:gravity="center">
<Button android:layout_height="wrap_content" android:text=""
android:id="@+id/blog" android:layout_width="wrap_content" android:background="@drawable/blog" android:onClick="onblog"></Button>
<TextView android:text="Blog" android:id="@+id/TextView04"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000"></TextView>
</LinearLayout>
</LinearLayout>
*******************************************************************************
Include usability
add this tag to your activity layout where you want to locate it and my advice it to use relative layout as it is good way to locate at bottom or on top
<include android:id="@+id/foot" layout="@layout/footer"></include>
Now to code for the class which would be extended by all the other classes in which this bar needs to be inserted.
make class for eg. basetabactivity and imply all the functions of bar buttons
public class basetabactivity extends Activity {
Button home, appointment, ques, blog;
applicationob app;
LinearLayout li;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.footer);
app = (applicationob) getApplication();
home = (Button) findViewById(R.id.home);
appointment = (Button) findViewById(R.id.appointment);
ques = (Button) findViewById(R.id.ques);
blog = (Button) findViewById(R.id.blog);
}
public void setcontent(int id) {
li = (LinearLayout) findViewById(R.id.foot);
home = (Button) findViewById(R.id.home);
appointment = (Button) findViewById(R.id.appointment);
ques = (Button) findViewById(R.id.ques);
blog = (Button) findViewById(R.id.blog);
}
public void onhome(View v) {
startActivity(new Intent(this, lawyer.class).addFlags(
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT).addFlags(
Intent.FLAG_ACTIVITY_SINGLE_TOP));
}
public void onapp(View v) {
startActivity(new Intent(this, appointment.class).addFlags(
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT).addFlags(
Intent.FLAG_ACTIVITY_SINGLE_TOP));
}
public void onques(View v) {
startActivity(new Intent(this, Quest.class).addFlags(
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT).addFlags(
Intent.FLAG_ACTIVITY_SINGLE_TOP));
}
public void onblog(View v) {
startActivity(new Intent(this, Blog.class).addFlags(
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT).addFlags(
Intent.FLAG_ACTIVITY_SINGLE_TOP));
}
}
Now if you have to extend this class in which you want the bottom bar to be functioned like if you want abc class to perform that bottom bar then you will simply extend that class
public class abc extends basetabactivity{
oncreate{
setcontentView(R.layout.footer);//include layout of footer first
setcontentView(R.layout.abc);// secondly layout of abc
}
}
Hope this code will help you in developing the bottom bar stuff any queries feel free to drop your comments
have a good programming!!!