2013-06-17 2 views
14

ナビゲーション項目を/折りたたみ可能にする方法それがここで説明されたように私は、「折りたたみナビゲーション項目」を作成します:ここで http://developer.android.com/design/patterns/navigation-drawer.html#Contentアンドロイド:ナビゲーションドロワーサブメニュー:</p> <p>どのように折りたたみ可能な私は オプション#5は、拡張可能であるある種の(サブメニューのような)別の7つのオプションがありshoudl 10のオプションでナビゲーションドロワーを持って

+0

それはExpandableListViewだ、あなたは実際に私が親5&親7に子を追加する必要がある唯一の親5. – Milan

+0

@Milanixに子を追加することができ、可能ではないということでしょうか? –

+0

何が問題なのですか?前述のようにExplandableListViewを使用してください。 – Milan

答えて

17

はそれを作るサンプルアプリケーションです:

PrashamTrivedi/DrawerLayoutTest

@Override 
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) 
    { 
     if (convertView == null) 
     { 
      LayoutInflater layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
      convertView = layoutInflater.inflate(R.layout.drawer_group_item,parent,false); 
     } 

     ((TextView) convertView).setText(groupItem.get(groupPosition)); 
     convertView.setTag(groupItem.get(groupPosition)); 
     return convertView; 
    } 

@Override 
    public View getChildView(int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) 
    { 
     tempChild = (ArrayList<String>) children.get(groupPosition); 
     TextView text = null; 

     if (convertView == null) 
     { 
      LayoutInflater layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
      convertView = layoutInflater.inflate(R.layout.drawer_submenu_item,parent,false); 
     } 

     text = (TextView) convertView; 
     text.setText(tempChild.get(childPosition)); 

     convertView.setTag(tempChild.get(childPosition)); 
     return convertView; 
} 

そして、あなたはレイアウトフォルダ(ヒント:2、グループビューのための1つを作成し、サブメニューのための他)で新しいXMLファイルを作成する必要が

すべてのサイドナビゲーションは、次のようにする必要があります。

Snapshot of drawer submenu view

EDIT:Simple Navigational Drawer Layout in Android

+0

プロジェクトソリューションを自分のワークスペースにインポートした後、アイテム4の項目を選択できませんでした。アイデアはありますか? –

+0

覚えているように、サンプルプロジェクトは完全に下位互換性がありませんでした。これは、min-sdkバージョン11があることを意味しています。ハニーコムAPIの前にある古いデバイスでこのアプリケーションを使用した場合、そうでない場合は、私が言ったアドバイスについて考えてみてください。 "新しいxmlファイルをレイアウトフォルダに作成する必要があります(ヒント:2つ、グループビュー用とサブメニュー用)。 – CagCak

+0

リンクが壊れています! – transistor

関連する問題