0

我已经创建了两个选项卡。选项卡 A 和选项卡 B。从选项卡 A,我正在导航到新活动说 C。从 C 如何导航到特定活动的选项卡 A。当我尝试时,它正在打开新活动,我无法调用选项卡中存在的活动。请帮助我。

public class TabsActivity extends TabActivity {
String Activity;
Intent i;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tabs);


    TabHost tabHost = getTabHost();

    // Tab for Photos
    TabSpec photospec = tabHost.newTabSpec("Tab A");
    // setting Title and Icon for the Tab
    photospec.setIndicator("Tab A");
    Intent photosIntent = new Intent(this, A.class);
    photospec.setContent(photosIntent);

    // Tab for Songs

    TabSpec songspec = tabHost.newTabSpec("Tab B");        
    songspec.setIndicator("Tab B");

    Intent songsIntent = new Intent(this, B.class);
    songspec.setContent(songsIntent);

    // Tab for Videos


    // Adding all TabSpec to TabHost
    tabHost.addTab(photospec); // Adding photos tab
    tabHost.addTab(songspec); // Adding songs tab

}

在使用按钮的活动中,我正在移动到另一个活动..例如:NewActivity

在 NewActivity 中,如何切换回 Tabs 中的 A。

新活动.java

public void onClick(View arg0) {
                // TODO Auto-generated method stub
                Intent intent = new Intent(ListActivity.this,
         listsearchbutton = (Button) findViewById(R.id.listfilter);
        listsearchbutton.setOnClickListener(new View.OnClickListener() {

            @Override
                        TabsActivity.class);
                intent.putExtra("Activity", "A");
            //i dont know where to use getIntent in TabsActivity to call A activity
                startActivity(intent);
            }

        });

提前致谢。

4

2 回答 2

0

只需Activityname.this.finish();单击按钮即可

于 2013-10-17T11:55:23.387 回答
0

换这个,

intent.putExtra("Activity", "A");
            //i dont know where to use getIntent in TabsActivity to call A activity
                startActivity(intent);

对此,

  finish();
于 2013-10-17T11:52:57.167 回答