2011-12-28 11 views
4

私のアプリケーションの各アクティビティのフッタのようなタブを再利用したい。フッタのようなAndroidタブ

私はこのコード

<TabHost 
     android:id="@android:id/tabhost" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     <RelativeLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" > 

      <FrameLayout 
       android:id="@android:id/tabcontent" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" 
       android:layout_above="@android:id/tabs" /> 

      <TabWidget 
       android:id="@android:id/tabs" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true" /> 

     </RelativeLayout> 

    </TabHost> 

を使用していると私は、各レイアウトのための私のタブの上のリストビュー、ボタンなどのようなコンポーネントを追加します。これをどうすれば管理できますか?

+0

[ActivityGroup](http://stackoverflow.com/q/4601475/593709)を使用してください。ただし、これは現在値下げされています。 –

答えて

2

私は共通の基本アクティビティを拡張することで同様のことを行いました。これは、setContentViewメソッドをオーバーライドしました。

abstract public class BaseActivity extends Activity { 
    @Override 
    public void setContentView(View view) { 

     // get master 
     LayoutInflater inflater = LayoutInflater.from(this); 

     // this is the master view with a container and the footer, you can 
     // as well add the header 
     RelativeLayout rlMasterView = (RelativeLayout) inflater.inflate(R.layout.master, null); 

     rlMasterView.addView(view); 

     super.setContentView(rlMasterView); 
    } 
} 

setContentViewはフッタを作成し、私が各アクティビティで設定しているビューにそれを添付します。

各レイアウトでincludeタグを使用することもできます。

<include src="footer" /> 
+0

あなたはそれを共有してもらえますか? – BCK

+2

私はこれがあなたに役立つことを願っています... – sebataz

+0

私は各レイアウトでTabHostを使いたいのですが、これをどのように管理できますか?たとえば、私のレイアウトにはListView、Button、タブがあります。 – BCK

関連する問題