1

In one of my applications I have used a tab bar with the help of {{tabactivity}} and {{activitygroup}} for displaying the tab bar in every screen.

I want to detect a second click on the already selected tab and implement a feature similar to the iPhone UITabbar. On a second click it will come to the initial activity.

public class Tabmanagement extends TabActivity{

public static Button back;
public static TextView text;
public static Button next;


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.tabmanagement);

    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    Resources res = getResources();
    TabHost tabHost = getTabHost();
    TabHost.TabSpec spec;
    Intent intent;

    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.windowstitle);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

    back=(Button)findViewById(R.id.Btn_Back);
    text = (TextView) findViewById(R.id.Text_Title);
    next=(Button)findViewById(R.id.Btn_Search);  


    spec = tabHost  .newTabSpec("tab1")
    .setIndicator("Topics",res.getDrawable(R.drawable.topics))
    .setContent(new Intent(this,FirstGroup.class)
    .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
    tabHost.addTab(spec);




    spec = tabHost  .newTabSpec("tab2")
    .setIndicator("Posts",res.getDrawable(R.drawable.post))
    .setContent(new Intent(this,SecondGroup.class)
    .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
    tabHost.addTab(spec);



    intent = new Intent().setClass(this, ThirdGroup.class);

    spec = tabHost  .newTabSpec("tab3")
                    .setIndicator("Response",res.getDrawable(R.drawable.response))
                    .setContent(intent);

    tabHost.addTab(spec);


    intent = new Intent().setClass(this, FourthGroup.class);

    spec = tabHost  .newTabSpec("tab4")
                    .setIndicator("Settings",res.getDrawable(R.drawable.settings))
                    .setContent(intent);

    tabHost.addTab(spec);
    tabHost.setCurrentTab(0);

    }

}
xan
  • 7,440
  • 8
  • 43
  • 65
Dharmendra Barad
  • 949
  • 6
  • 14
  • Can you add the relevant code to make it easier to give you examples? – Henry Dec 10 '12 at 11:05
  • http://stackoverflow.com/a/7750320/1339473 try this one.. you problem will be solved.. here i think @DON – QuokMoon Dec 10 '12 at 11:31
  • possible duplicate of [how to detecting a click on an already selected tab button](http://stackoverflow.com/questions/9372851/how-to-detecting-a-click-on-an-already-selected-tab-button) – bummi Nov 01 '14 at 23:00

1 Answers1

0

I think this is what you're looking for. Essentially get a hold of the TabWidget from the TabHost and set the proper listeners on the view.

how to detecting a click on an already selected tab button

Community
  • 1
  • 1
Viet Nguyen
  • 142
  • 3
  • 8