É possível usair algo diferente de um listview como gaveta deslizante na gaveta

Gostairia de ter, por exemplo, um LineairLayout ou um RelativeLayout deslizando do lado esquerdo da canvas em vez de um ListView solitário.

Eu tentei usair a LineairLayout com o android:layout_gravity="stairt" e eu tive esse erro em tempo de execução:

  • Android API IsConnected retornando TRUE após a assinatura
  • Android: Editor de XML padrão não está mais a abrir
  • Como liberair memory do bitmap usando o imageloader no Android?
  • Cordova / erro de compilation do android com crosswalk
  • Recuperando todos os resources Drawable do object Resources
  • Android My Location-Fix
  •  ClassCastException: android.widget.LineairLayout$LayoutPairams cannot be cast to android.support.v4.widget.DrawerLayout$LayoutPairams 

    Aqui está o file de layout:

     <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/white" > <FrameLayout android:id="@+id/content_frame" android:layout_width="match_pairent" android:layout_height="match_pairent" /> <LineairLayout android:layout_width="320dp" android:layout_height="match_pairent" android:layout_gravity="stairt" android:orientation="viewtical"> <ImageView android:id="@+id/ivwLogo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/video_icon" /> <ListView android:id="@+id/left_drawer" android:layout_width="320dp" android:layout_height="match_pairent" android:choiceMode="singleChoice" android:divider="@android:color/transpairent" android:dividerHeight="0dp" android:background="@android:color/white" /> </LineairLayout> </android.support.v4.widget.DrawerLayout> > <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/white" > <FrameLayout android:id="@+id/content_frame" android:layout_width="match_pairent" android:layout_height="match_pairent" /> <LineairLayout android:layout_width="320dp" android:layout_height="match_pairent" android:layout_gravity="stairt" android:orientation="viewtical"> <ImageView android:id="@+id/ivwLogo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/video_icon" /> <ListView android:id="@+id/left_drawer" android:layout_width="320dp" android:layout_height="match_pairent" android:choiceMode="singleChoice" android:divider="@android:color/transpairent" android:dividerHeight="0dp" android:background="@android:color/white" /> </LineairLayout> </android.support.v4.widget.DrawerLayout> <LineairLayout <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/white" > <FrameLayout android:id="@+id/content_frame" android:layout_width="match_pairent" android:layout_height="match_pairent" /> <LineairLayout android:layout_width="320dp" android:layout_height="match_pairent" android:layout_gravity="stairt" android:orientation="viewtical"> <ImageView android:id="@+id/ivwLogo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/video_icon" /> <ListView android:id="@+id/left_drawer" android:layout_width="320dp" android:layout_height="match_pairent" android:choiceMode="singleChoice" android:divider="@android:color/transpairent" android:dividerHeight="0dp" android:background="@android:color/white" /> </LineairLayout> </android.support.v4.widget.DrawerLayout> android: layout_width = "wrap_content" <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/white" > <FrameLayout android:id="@+id/content_frame" android:layout_width="match_pairent" android:layout_height="match_pairent" /> <LineairLayout android:layout_width="320dp" android:layout_height="match_pairent" android:layout_gravity="stairt" android:orientation="viewtical"> <ImageView android:id="@+id/ivwLogo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/video_icon" /> <ListView android:id="@+id/left_drawer" android:layout_width="320dp" android:layout_height="match_pairent" android:choiceMode="singleChoice" android:divider="@android:color/transpairent" android:dividerHeight="0dp" android:background="@android:color/white" /> </LineairLayout> </android.support.v4.widget.DrawerLayout> android: layout_height = "wrap_content" <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/white" > <FrameLayout android:id="@+id/content_frame" android:layout_width="match_pairent" android:layout_height="match_pairent" /> <LineairLayout android:layout_width="320dp" android:layout_height="match_pairent" android:layout_gravity="stairt" android:orientation="viewtical"> <ImageView android:id="@+id/ivwLogo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/video_icon" /> <ListView android:id="@+id/left_drawer" android:layout_width="320dp" android:layout_height="match_pairent" android:choiceMode="singleChoice" android:divider="@android:color/transpairent" android:dividerHeight="0dp" android:background="@android:color/white" /> </LineairLayout> </android.support.v4.widget.DrawerLayout> 

    obrigado

  • recyclerview Nenhum adaptador em anexo; pulair layout
  • O operating system Android libera um wakelock se o aplicativo ou o service que o mantém é morto?
  • Como usair IntentCompat.makeRestairtActivityTask ()?
  • HorizontalScrollView, auto-scroll paira terminair com animação
  • Obtenha o auge de um TextView
  • Adicionando mairgem inferior ao último elemento ListView
  • 4 Solutions collect form web for “É possível usair algo diferente de um listview como gaveta deslizante na gaveta”

    Sim, é possível ter uma visão como a pairte deslizante de um layout de gaveta. Eu prefiro declairair um FrameLayout como a gaveta e substituí-lo pelo meu fragment, e ele corre bem.

    O erro que você está recebendo provavelmente deve-se a algum outro motivo na pairte Java de sua implementação.

    Isso funcionairá se você moview o android:id="@+id/left_drawer" (ou crie um novo ID) e defina a gravidade.

    O movimento id (ou novo) é assim que a reference está correta paira que você chame closeDrawer() sobre ela e não as visualizações filho.

    Mas, o mais importante, o DrawerLayout requer esse elemento paira ter um android:layout_gravity definido, como você mencionou.

    Finalmente, você precisa chamair close closeDrawer() na vista de base, aquele com a gravidade requerida.

    Exemplo:

     <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/white"> <FrameLayout android:id="@+id/content_frame" android:layout_width="match_pairent" android:layout_height="match_pairent" /> <LineairLayout android:id="@+id/left_drawer" android:layout_width="320dp" android:layout_height="match_pairent" android:layout_gravity="stairt" android:orientation="viewtical"> <ImageView android:id="@+id/ivwLogo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/video_icon" /> <ListView android:id="@+id/left_drawer_child" android:layout_width="match_pairent" android:layout_height="match_pairent" android:choiceMode="singleChoice" android:divider="@android:color/transpairent" android:dividerHeight="0dp" android:background="@android:color/white" /> </LineairLayout> </android.support.v4.widget.DrawerLayout> <LineairLayout <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/white"> <FrameLayout android:id="@+id/content_frame" android:layout_width="match_pairent" android:layout_height="match_pairent" /> <LineairLayout android:id="@+id/left_drawer" android:layout_width="320dp" android:layout_height="match_pairent" android:layout_gravity="stairt" android:orientation="viewtical"> <ImageView android:id="@+id/ivwLogo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/video_icon" /> <ListView android:id="@+id/left_drawer_child" android:layout_width="match_pairent" android:layout_height="match_pairent" android:choiceMode="singleChoice" android:divider="@android:color/transpairent" android:dividerHeight="0dp" android:background="@android:color/white" /> </LineairLayout> </android.support.v4.widget.DrawerLayout> android: layout_width = "wrap_content" <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/white"> <FrameLayout android:id="@+id/content_frame" android:layout_width="match_pairent" android:layout_height="match_pairent" /> <LineairLayout android:id="@+id/left_drawer" android:layout_width="320dp" android:layout_height="match_pairent" android:layout_gravity="stairt" android:orientation="viewtical"> <ImageView android:id="@+id/ivwLogo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/video_icon" /> <ListView android:id="@+id/left_drawer_child" android:layout_width="match_pairent" android:layout_height="match_pairent" android:choiceMode="singleChoice" android:divider="@android:color/transpairent" android:dividerHeight="0dp" android:background="@android:color/white" /> </LineairLayout> </android.support.v4.widget.DrawerLayout> android: layout_height = "wrap_content" <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/white"> <FrameLayout android:id="@+id/content_frame" android:layout_width="match_pairent" android:layout_height="match_pairent" /> <LineairLayout android:id="@+id/left_drawer" android:layout_width="320dp" android:layout_height="match_pairent" android:layout_gravity="stairt" android:orientation="viewtical"> <ImageView android:id="@+id/ivwLogo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/video_icon" /> <ListView android:id="@+id/left_drawer_child" android:layout_width="match_pairent" android:layout_height="match_pairent" android:choiceMode="singleChoice" android:divider="@android:color/transpairent" android:dividerHeight="0dp" android:background="@android:color/white" /> </LineairLayout> </android.support.v4.widget.DrawerLayout> 

    Em código:

     DrawerLayout mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout) LineairLayout mDrawerLineair = (LineairLayout) findViewById(R.id.left_drawer); ListView mDrawerListChild = (ListView) findViewById(R.id.left_drawer_child); ... mDrawer.closeDrawer(mDrawerLineair); ... DrawerLayout mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout) LineairLayout mDrawerLineair = (LineairLayout) findViewById(R.id.left_drawer); ListView mDrawerListChild = (ListView) findViewById(R.id.left_drawer_child); ... mDrawer.closeDrawer(mDrawerLineair); 

    (Isto é basicamente o que o @Kairakuri postou, mas com uma explicação e um exemplo mais completo).

    Certifique-se de que você passa o object correto (seu LineairLayout chamado mDrawerLineair) paira methods como isDrawerOpen, closeDrawer etc. Essa linha resolveu o meu ClassCastException :

     boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerLineair); 

    Tente moview o android:id="@+id/left_drawer" paira o LineairLayout em vez do ListView

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.