With the help of these program, I created the Tabs. you can look at a below Codes.
HomeActivity.java:
package com.sit.fth.activity;
import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.WindowManager;
public class HomeActivity extends BaseActivity implements
VideoFragment.OnVideoSelectedListener,
AboutFragment.OnAboutFragmentSelectedListener,
AnnouncenentFragment.OnAnnouncementSelectedListener,
GalleryFragment.OnGalItemSelectedListener,
MagzineFragment.OnMagzineSelectedListener {
private ActionBar actionabar;
private ViewPager viewpager;
private LiveStreamFragment liveStreamFragment;
private AppData appData;
private FragmentManager fm;
private MyFragmentPagerAdapter fragmentPagerAdapter;
// private HomeBaseFragment fragment;
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
setContentView(R.layout.activity_main);
appData = ((GemsApplication) this.getApplication()).getAppData();
actionabar = getActionBar();
actionabar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
liveStreamFragment = new LiveStreamFragment();
viewpager = (ViewPager) findViewById(R.id.pager);
fm = getSupportFragmentManager();
/** Defining a listener for pageChange */
ViewPager.SimpleOnPageChangeListener pageChangeListener = new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
super.onPageSelected(position);
actionabar.setSelectedNavigationItem(position);
}
};
/** Setting the pageChange listner to the viewPager */
viewpager.setOnPageChangeListener(pageChangeListener);
/** Creating an instance of FragmentPagerAdapter */
fragmentPagerAdapter = new MyFragmentPagerAdapter(fm);
viewpager.setAdapter(fragmentPagerAdapter);
actionabar.setDisplayShowTitleEnabled(true);
/** Defining tab listener */
ActionBar.TabListener tabListener = new ActionBar.TabListener() {
@Override
public void onTabReselected(Tab arg0,
android.app.FragmentTransaction arg1) {
}
@Override
public void onTabSelected(Tab tab,
android.app.FragmentTransaction ft) {
viewpager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(Tab tab,
android.app.FragmentTransaction ft) {
}
};
Tab tab = actionabar.newTab().setText(getString(R.string.str_home))
.setTabListener(tabListener);
actionabar.addTab(tab);
tab = actionabar.newTab().setText(getString(R.string.str_video))
.setTabListener(tabListener);
actionabar.addTab(tab);
tab = actionabar.newTab().setText(getString(R.string.str_gal))
.setTabListener(tabListener);
actionabar.addTab(tab);
tab = actionabar.newTab().setText(getString(R.string.str_announcements))
.setTabListener(tabListener);
actionabar.addTab(tab);
tab = actionabar.newTab()
.setText(getString(R.string.str_magazines))
.setTabListener(tabListener);
actionabar.addTab(tab);
tab = actionabar.newTab().setText(getString(R.string.str_conduct))
.setTabListener(tabListener);
actionabar.addTab(tab);
}
}
I need to move a tab to the bottom of the screen.I am getting confused because I add a tabs
with the help of HomeActivity.java coding not from xml layout
.
I doesn't know how to move the tab to the bottom of the screen.Anybody can help me with these.Thank You.