Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/193.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从android中的其他活动调用特定活动的选项卡_Android_Android Intent_Android Tabhost - Fatal编程技术网

如何从android中的其他活动调用特定活动的选项卡

如何从android中的其他活动调用特定活动的选项卡,android,android-intent,android-tabhost,Android,Android Intent,Android Tabhost,我已经创建了两个选项卡。选项卡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(Bu

我已经创建了两个选项卡。选项卡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中,如何切换回选项卡中的

NewActivity.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);
            }

        });
提前感谢。

替换此

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

  finish();

只需使用
Activityname.this.finish()在按钮上单击

而不使用finish,您知道怎么做吗?