2012-01-20 6 views
3

TabViewListActivity이 표시되지만 목록 항목 중 하나를 클릭 할 때마다 새로운 활동으로 연결되고 TabView는 완전히 사라집니다.Android : 새로운 활동을 탭 안에 유지하십시오

내가 원하는 것은 목록의 항목 중 하나를 클릭하면 새 활동이 표시되고 여전히 탭 안에 유지됩니다.

아무도 내 코드 개선에 도움이 될 수 있습니까?

다음은 사용자 정의 TabView에 대한 내 코드입니다 :

super.onCreate(savedInstanceState); 
    // construct the tabhost 
    setContentView(R.layout.project_tab); 

    setupTabHost(); 

    setupTabL(new TextView(this), "Alle", (ProjectsList.class)); 
    setupTab(new TextView(this), "Kategorien", (CategoryList.class)); 
    setupTabR(new TextView(this), "Favorites", (ProjectsList.class)); 

    final Button refresh = (Button) findViewById(R.id.btn_project_refresh); 
    refresh.setOnClickListener(refresh_listener); 
} 

private void setupTab(final View view, final String tag, final Class<?> context) { 
    View tabview = createTabView(mTabHost.getContext(), tag); 
    TabSpec ts1 = mTabHost.newTabSpec("tab1"); 
    ts1.setIndicator(tabview); 
    mTabHost.addTab(ts1); 
} 

private static View createTabView(final Context context, final String text) { 
    View view = LayoutInflater.from(context).inflate(R.layout.inner_tab_m_bg, null); 
    TextView tv = (TextView) view.findViewById(R.id.tabsText); 
    tv.setText(text); 
    return view; 
} 

이는 ListActivity의 코드에서 onListItemClick 조각입니다 : 당신이 찾고있는 것은 활동 그룹이

protected void onListItemClick(ListView l, View v, int position, long id) { 
     super.onListItemClick(l, v, position, id); 
     Object o = this.getListAdapter().getItem(position); 
     String choice = o.toString(); 
     if (choice .equals("Entwicklungshilfe")) { 
      Intent i = new Intent(CategoryList.this, SubCategoryList.class); 
      i.putExtra("category","'%Entwicklungshilfe%'"); 
      startActivityForResult(i,0); 

답변

관련 문제