我的应用程序中有选项卡布局和两个标签。
- 标签1 - 我的应用程序
- 标签2 - 任何外部Android应用程序(如联系人、呼叫拨号等)(我知道如何启动外部应用程序,但它不会在我的应用程序中运行(意味着在启动后选项卡不会显示))。
提前感谢。
我的应用程序中有选项卡布局和两个标签。
提前感谢。
在我看来,这是不可能的。
你只能在 TabHost
中显示自己的活动。对于外部活动,你需要一个隐式意图,但是 TabHost
不支持此功能:将外部 Intent 嵌入主 Activity
因此,你需要在自己的活动中显示来自其他应用程序的数据。为此,你需要查询其他应用程序提供的内容提供程序(请参见 http://developer.android.com/guide/topics/providers/content-providers.html),并在列表活动中包含此 ListActivity
(请参见 http://developer.android.com/reference/android/app/ListActivity.html)并将其包含在你的 TabHost 中。
阅读文档(意图部分),以下是一些例子:
public class MyTab extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final TabHost tabHost = getTabHost();
Intent taskIntent = new Intent(this, Public.class);
taskIntent.putExtra(Intent.ACTION_VIEW, "public");
TabHost.TabSpec tsValid = tabHost.newTabSpec("public");
tsValid.setIndicator(getText(R.string.tab_title_public));
tsValid.setContent(taskIntent);
tabHost.addTab(tsValid);
Intent annIntent = new Intent(this, Private.class);
annIntent.putExtra(Intent.ACTION_VIEW, "private");
TabHost.TabSpec tsGenerate = tabHost.newTabSpec("private");
tsGenerate.setIndicator(getText(R.string.tab_title_private));
tsGenerate.setContent(annIntent);
tabHost.addTab(tsGenerate);
}
}