tags:

views:

24

answers:

1

I have created two tabs, say TAB1 and TAB2. For TAB1, i have loaded one Activity, say ActivityOne, into TAB1 as

Intent intent = new Intent(this,ActivityOne.class);
    TabHost.TabSpec spec = getTabHost().newTabSpec("ActivityOne")
                                       .setIndicator("Activity One",getResources().getDrawable(R.drawable.artists)).setContent(intent);
    getTabHost().addTab(spec);

This ActivityOne has extended the ActivityGroup and i added one button in this activity. By clicking on this button it will call another activity, say ActivityOne_One, as

public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(ActivityOne.this,ActivityOne_One.class);
            replaceContentView("ActivityOne_One",intent);
        }
public void replaceContentView(String id, Intent intent){
    View view = this.getLocalActivityManager().startActivity(id, intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
        this.setContentView(view);
}

When we click on that button ActivityOne_One will be launched under same TAB1. In this application i have two problems: 1) If i want to go back to ActivityOne under same TAB1 by using traditional BACK button on emulator it is not working.. 2)ActivityOne_One is launching with no animation(like sliding from right to left) effect.

If anyone know about any one of these, give your advice..

Thanks,
venu

A: 

see this link which may help you out with this. http://blog.henriklarsentoft.com/2010/07/android-tabactivity-nested-activities/

i have implemented what is advised in the link i provided. it works OK, but it is quirky and does not always redirect you BACK like you would expect. i have found that you must implement your own custom tabs to really get this desired effect.

binnyb
hi binnyb..thanks for your reply. I have seen that blog and faced one problem in back() method. We added view to history(ArrayList) in replaceView() method.The problem is, Suppose if we are in CitiesActivity (so the history size is one) and clicked the BACK button, the code in the back() method is executed as 1)only one element in history(ArrayList) will be removed,now the history size is zero. 2)calling setContentView(history.get(history.size()-1)); gives java.lang.ArrayIndexOutOfBoundException..So how can i execute this code?? if you dont mind can you guide me in a proper way to get solution
Venu Gopal