2012-10-11 2 views
5

横のメニューをアンドロイドで作成します。 Androidは縦方向に拡張できる拡張可能なリストビューをサポートしていますが、横にメニューを展開したいと考えています。画像をご参照ください横のメニュー

enter image description here

説明:画像で

メニュー1、MENU2、MENU3は、メインメニューで、私は、メインメニューでそのサブをクリックした場合はS1、S2、S3は、メニュー1のサブ項目ですアイテムは展開する必要があります。

答えて

3

あなたは、それは単純な例ですonClickListener

1

でのLinearLayoutにサブメニューを入れて、View.VISIBLE/View.GONEでプレイを追加することができます。 自分で完了してください。

(xml)。 btn_menu1で

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/attachments_list" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal"> 
    <Button 
     android:id="@+id/btn_menu1" 
     android:layout_width="0dp" 
     android:layout_height="50dp" 
     android:text="Menu1" 
     android:layout_weight="1" 
     /> 
    <LinearLayout 
     android:id="@+id/subview_menu1" 
     android:layout_width="0dp" 
     android:layout_height="50dp" 
     android:layout_weight="2" 
     android:visibility="gone" 
     > 
     <Button 
      android:layout_width="0dp" 
      android:layout_height="fill_parent" 
      android:text="S1" 
      android:layout_weight="1" 
      /> 
     <Button 
      android:layout_width="0dp" 
      android:layout_height="fill_parent" 
      android:text="S2" 
      android:layout_weight="1" 
      /> 
     <Button 
      android:layout_width="0dp" 
      android:layout_height="fill_parent" 
      android:text="S3" 
      android:layout_weight="1" 
      /> 
    </LinearLayout> 
    <Button 
     android:layout_width="0dp" 
     android:layout_height="50dp" 
     android:text="Menu2" 
     android:layout_weight="1" 
     /> 
    <Button 
     android:layout_width="0dp" 
     android:layout_height="50dp" 
     android:text="Menu3" 
     android:layout_weight="1" 
     /> 
    </LinearLayout> 

OnClickListener

public void onClick(View v) { 
    if (subview_menu1.isShown()) { 
     subview_menu1.setVisibility(View.GONE); 
    } 
    else{ 
     subview_menu1.setVisibility(View.VISIBLE); 
    } 
} 
+0

おかげで私はそれを得たが、私はrandom.Iは今のおかげで、それはそれを管理します行う方法についてのアイデアを持っていることを生成する必要があります。 –

関連する問題