2012-10-11 8 views
5

Chcę utworzyć poziome menu w systemie Android. Android obsługuje rozwijany widok listy, który rozwija się pionowo, ale chcę rozwijać menu w poziomie. Proszę odnieść się obrazMenu poziome

enter image description here

Opis:

W obrazach menu1, Menu2, menu3 to główne menu i s1, s2, s3 są podrzędne pozycje menu 1. Jeżeli kliknięciu na menu głównym jego sub przedmioty muszą być rozwinięte.

Odpowiedz

3

podmenu można umieścić w LinearLayout i dodać gry z View.VISIBLE/View.GONE w onClickListener

1

To prosty przykład. powinieneś ukończyć samodzielnie.

w formacie xml.

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

w btn_menu1 OnClickListener

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

Dzięki mam go, ale mam do generowania że random.I wpadł na pomysł, jak to zrobić będzie nią zarządzać teraz dzięki. –

Powiązane problemy