1

Вот мой кодTabhost не появляется при открытой новой деятельности из стороны вкладки

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. Активность открыта, но Tabhost не появляется

Пожалуйста, помогите мне, как я могу исправить эту проблему

Заранее спасибо

+0

Не можно указать свою ошибку с этим меньшим количеством коды. Опубликуйте больше кода с объявлением tabhost. – AabidMulani

+0

Я не получаю ошибки в этом коде, используя для открытия новой активности внутри tabHost – deep

+0

Это очень важно для меня, и я новичок в android. Пожалуйста, ознакомьтесь с моим вопросом и дайте мне предложение решить проблему. – deep

ответ

0
public class Tab_Bar extends TabActivity { 
    TabHost tabHost; 
public void onCreate(Bundle savedInstanceState) { 
super.onCreate(savedInstanceState); 
setContentView(R.layout.tab); 
tabHost = getTabHost(); 
tabHost.setup(); 
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) 
{ 

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); 

} 

} 
+0

Спасибо за повтор, тогда как я могу исправить это issue – deep

+0

check updated ans – Sush

+0

Я не хочу добавлять активность на панели вкладок, я хочу, чтобы простая открытая активность, но панель вкладок также доступна со старым виджетами – deep

Смежные вопросы