【发布时间】:2014-01-03 19:41:27
【问题描述】:
这是我的代码
View view = getLocalActivityManager().startActivity("recently_viewd",
new Intent(context,Job_Description.class)
.putExtra("line", result)
.putExtra("limit",0)
.putExtra("Alert", false)
.putExtra("str_Descrption",edit_Jobdesc.getText().toString().trim())
.putExtra("str_location", edit_JobLoc.getText().toString().trim()).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
.getDecorView();
setContentView(view);
TabActiviy.class
public class Tab_Bar extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab);
setTabs() ;
}
void setTabs()
{
addTab("My Profile", R.drawable.home_normal, MyProfile.class);
addTab("Search", R.drawable.search_normal, JobSearch.class);
addTab("Saved Jobs", R.drawable.starred, Saved_jobs.class);
addTab("Job Alert", R.drawable.job_match, JobAlert.class);
}
private void addTab(String labelId, int drawableId, Class<?> c)
{
TabHost tabHost = getTabHost();
Intent intent = new Intent(this, c);
TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);
View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false);
TextView title = (TextView) tabIndicator.findViewById(R.id.title);
title.setText(labelId);
ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
icon.setImageResource(drawableId);
spec.setIndicator(tabIndicator);
spec.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(1);
}
}
我正在使用此代码在 TabHost 中打开新活动。 Activity 已打开,但 Tabhost 未出现
请帮我解决这个问题
提前致谢
【问题讨论】:
-
不可能用这么少的代码指出你的错误。使用 tabhost 声明发布更多代码。
-
我没有收到任何错误,此代码用于在 tabHost 中打开新活动
-
这对我来说非常重要,我是 android 新手,请查看我的问题并给我一个解决问题的建议
标签: android android-fragments android-tabs android-tabactivity