2011-10-28 13 views
2

私のアプリケーションには2つのタブがあります。私はタブ1をクリックすると、それは私が1つのアクティビティを使用Androidのリストビューのタイトル

[ tab1 ][ tab2 ] 
title 1 
listview1 item 
listview1 item 
........ 
title 2 
listview2 item 
listview2 item 
........ 

各タブ

の下などのGoogleリーダーのようなインターフェイスを、表示されます。このようなインターフェースを持つ方法を教えてください。私はちょうど4日:(用アンドロイドで始まるおかげであなた

PS:。!。私はTAB1にタイトルなし1つのリストビューを追加することができますが、そのような2つのタイトルで2つのリストビューを追加する方法がわからない

+0

あなたの親ビュー(タブ)にTextView、ListView、TextView、ListView(TextViewsはあなたのタイトルになります)を追加する必要があるタイトルを取得するには、エディタでそのようなレイアウトを作成してみてください – Selvin

答えて

5

あなたはただ、複数のセクションヘッダと1つのリストビューを追加し、2つのタイトルを持つ2つのリストビューを追加する必要はありません。

ただ、その素敵なリストビューでセクション化されたヘッダを実装する方法を説明します。

を、このAndroid – Sectioned Headers in ListViews例を見て、

android-amazing-listview

Jeff Sharkey's SeparatedListAdapter

MergeAdapter by CommonsWare

感謝。

+0

2つのリストビューが必要なのは、それらのデータが異なるからです。早速お返事をいただきありがとうございます。 – Wayne

+0

異なるデータの場合、2つの文字列配列またはリストを管理し、それをマージして1つのリストビューに渡す必要があるため、2つのリストビューを管理する必要はありません。 – user370305

0

これはあなたのニーズに合わせなければならない:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 
    <LinearLayout 
     android:id="@+id/linearLayout1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:orientation="vertical" > 
     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Title 1" /> 
     <ListView 
      android:id="@+id/listView1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" > 
     </ListView> 
    </LinearLayout> 
    <LinearLayout 
     android:id="@+id/linearLayout2" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:orientation="vertical" > 
     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Title 2" /> 
     <ListView 
      android:id="@+id/listView2" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" > 
     </ListView> 
    </LinearLayout> 
</LinearLayout> 
0

次の2つのリストビューをオーバーラップする必要があり、両方が見えない(セットアンドロイド:可視性=「見えない」)をrをuがアプリケーションを起動するが、uはボタンTAB1のリスト1をクリックしたときにいつタブ2をクリックすると、リスト1が非表示になり、リスト2が表示されます。相対レイアウトを使用してリストをオーバーラップすることができます。両方のリストを表示および非表示にするには、フラグを使用する必要があります。