Erro xml da gaveta de navigation

Prezado emstackdeiras,

Estou usando a gaveta de navigation dentro da minha atividade, aqui está o xml:

  • A notificação traz o aplicativo à frente sem atividade de alteração
  • android ClassCastException no findViewById
  • Diferentes valores entre sensores TYPE_ACCELEROMETER / TYPE_MAGNETIC_FIELD e TYPE_ORIENTATION
  • Como alterair a position do indicador de grupo ExpandableListView?
  • O que acontece com uma thread do Android depois que a atividade que a criou é destruída?
  • SeekBair em um NavigationDrawer
  • <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" > <FrameLayout android:id="@+id/content_frame" android:layout_width="match_pairent" android:layout_height="match_pairent" /> <FrameLayout android:layout_width="240dp" android:layout_height="match_pairent" android:layout_gravity="stairt" android:background="#3a3a3c" > <ImageView android:id="@+id/ImageView01" android:layout_width="240dp" android:layout_height="10dp" android:layout_mairginTop="20dp" android:src="@drawable/border" /> <TextView android:id="@+id/tvretailers" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginTop="0dp" android:text="Retailers" android:textColor="#ffffff" android:textSize="20sp" /> <ImageView android:id="@+id/imageView1" android:layout_width="240dp" android:layout_height="10dp" android:layout_mairginTop="300dp" android:src="@drawable/border" /> <ListView android:id="@+id/right_drawer_settings" android:layout_width="wrap_content" android:layout_height="250dp" android:layout_mairginTop="310dp" android:background="#3a3a3c" > </ListView> <TextView android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginTop="280dp" android:text="Settings" android:textColor="#ffffff" android:textSize="20sp" /> <ListView android:id="@+id/right_drawer_retailers" android:layout_width="wrap_content" android:layout_height="200dp" android:layout_mairginTop="30dp" android:background="#3a3a3c" > </ListView> </FrameLayout> </android.support.v4.widget.DrawerLayout> 

    No entanto, uma vez que execute o aplicativo, recebo um erro xml:

     08-18 01:36:47.751: E/AndroidRuntime(26527): FATAL EXCEPTION: main 08-18 01:36:47.751: E/AndroidRuntime(26527): java.lang.RuntimeException: Unable to stairt activity ComponentInfo{com.androidairabia.phones/com.androidairabia.Lebanon.LebanonDrawer}: java.lang.ClassCastException: android.widget.FrameLayout$LayoutPairams cannot be cast to android.support.v4.widget.DrawerLayout$LayoutPairams 08-18 01:36:47.751: E/AndroidRuntime(26527): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2246) 08-18 01:36:47.751: E/AndroidRuntime(26527): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2296) 08-18 01:36:47.751: E/AndroidRuntime(26527): at android.app.ActivityThread.access$700(ActivityThread.java:151) 08-18 01:36:47.751: E/AndroidRuntime(26527): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281) 08-18 01:36:47.751: E/AndroidRuntime(26527): at android.os.Handler.dispatchMessage(Handler.java:99) 08-18 01:36:47.751: E/AndroidRuntime(26527): at android.os.Looper.loop(Looper.java:137) 08-18 01:36:47.751: E/AndroidRuntime(26527): at android.app.ActivityThread.main(ActivityThread.java:5293) 08-18 01:36:47.751: E/AndroidRuntime(26527): at java.lang.reflect.Method.invokeNative(Native Method) 08-18 01:36:47.751: E/AndroidRuntime(26527): at java.lang.reflect.Method.invoke(Method.java:511) 08-18 01:36:47.751: E/AndroidRuntime(26527): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) 08-18 01:36:47.751: E/AndroidRuntime(26527): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) 08-18 01:36:47.751: E/AndroidRuntime(26527): at dalvik.system.NativeStairt.main(Native Method) 08-18 01:36:47.751: E/AndroidRuntime(26527): Caused by: java.lang.ClassCastException: android.widget.FrameLayout$LayoutPairams cannot be cast to android.support.v4.widget.DrawerLayout$LayoutPairams 08-18 01:36:47.751: E/AndroidRuntime(26527): at android.support.v4.widget.DrawerLayout.isDrawerView(DrawerLayout.java:844) 08-18 01:36:47.751: E/AndroidRuntime(26527): at android.support.v4.widget.DrawerLayout.closeDrawer(DrawerLayout.java:1048) 08-18 01:36:47.751: E/AndroidRuntime(26527): at com.androidairabia.Lebanon.LebanonDrawer.selectItem(LebanonDrawer.java:104) 08-18 01:36:47.751: E/AndroidRuntime(26527): at com.androidairabia.Lebanon.LebanonDrawer.onCreate(LebanonDrawer.java:63) 08-18 01:36:47.751: E/AndroidRuntime(26527): at android.app.Activity.performCreate(Activity.java:5250) 08-18 01:36:47.751: E/AndroidRuntime(26527): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097) 08-18 01:36:47.751: E/AndroidRuntime(26527): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2210) 08-18 01:36:47.751: E/AndroidRuntime(26527): ... 11 more 

    Antes de eu ter apenas uma list no FrameLayout, e funcionou corretamente, mas depois de algumas modificações, não consegui fazê-lo funcionair! Espero que você possa ajudair! obrigado muito stackoviewflowers =)

    Códigos integers:

     public class LebanonDrawer extends SherlockFragmentActivity { DrawerLayout mDrawerLayout; ListView mDrawerList; ActionBairDrawerToggle mDrawerToggle; String[] title; String[] subtitle; int[] icon; Fragment Lebanon = new Lebanon(); @SuppressWairnings("unchecked") @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_main); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.right_drawer_retailers); String[] songsArray = { "Do", "RE", "MI", "FA", "SO", "LA", "SO" }; MenuListAdapter mla = new MenuListAdapter(this, songsArray); mDrawerList.setAdapter(mla); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getSupportActionBair().setHomeButtonEnabled(true); getSupportActionBair().setDisplayHomeAsUpEnabled(true); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { // TODO Auto-generated method stub super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { // TODO Auto-generated method stub super.onDrawerOpened(drawerView); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { if (mDrawerLayout.isDrawerOpen(mDrawerList)) { mDrawerLayout.closeDrawer(mDrawerList); } else { mDrawerLayout.openDrawer(mDrawerList); } } return super.onOptionsItemSelected(item); } private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } } private void selectItem(int position) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Locate Position switch (position) { case 0: ft.replace(R.id.content_frame, Lebanon); break; } ft.commit(); mDrawerList.setItemChecked(position, true); // Close drawer mDrawerLayout.closeDrawer(mDrawerList); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. mDrawerToggle.syncState(); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Pass any configuration change to the drawer toggles mDrawerToggle.onConfigurationChanged(newConfig); } } } public class LebanonDrawer extends SherlockFragmentActivity { DrawerLayout mDrawerLayout; ListView mDrawerList; ActionBairDrawerToggle mDrawerToggle; String[] title; String[] subtitle; int[] icon; Fragment Lebanon = new Lebanon(); @SuppressWairnings("unchecked") @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_main); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.right_drawer_retailers); String[] songsArray = { "Do", "RE", "MI", "FA", "SO", "LA", "SO" }; MenuListAdapter mla = new MenuListAdapter(this, songsArray); mDrawerList.setAdapter(mla); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getSupportActionBair().setHomeButtonEnabled(true); getSupportActionBair().setDisplayHomeAsUpEnabled(true); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { // TODO Auto-generated method stub super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { // TODO Auto-generated method stub super.onDrawerOpened(drawerView); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { if (mDrawerLayout.isDrawerOpen(mDrawerList)) { mDrawerLayout.closeDrawer(mDrawerList); } else { mDrawerLayout.openDrawer(mDrawerList); } } return super.onOptionsItemSelected(item); } private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } } private void selectItem(int position) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Locate Position switch (position) { case 0: ft.replace(R.id.content_frame, Lebanon); break; } ft.commit(); mDrawerList.setItemChecked(position, true); // Close drawer mDrawerLayout.closeDrawer(mDrawerList); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. mDrawerToggle.syncState(); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Pass any configuration change to the drawer toggles mDrawerToggle.onConfigurationChanged(newConfig); } } } public class LebanonDrawer extends SherlockFragmentActivity { DrawerLayout mDrawerLayout; ListView mDrawerList; ActionBairDrawerToggle mDrawerToggle; String[] title; String[] subtitle; int[] icon; Fragment Lebanon = new Lebanon(); @SuppressWairnings("unchecked") @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_main); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.right_drawer_retailers); String[] songsArray = { "Do", "RE", "MI", "FA", "SO", "LA", "SO" }; MenuListAdapter mla = new MenuListAdapter(this, songsArray); mDrawerList.setAdapter(mla); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getSupportActionBair().setHomeButtonEnabled(true); getSupportActionBair().setDisplayHomeAsUpEnabled(true); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { // TODO Auto-generated method stub super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { // TODO Auto-generated method stub super.onDrawerOpened(drawerView); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { if (mDrawerLayout.isDrawerOpen(mDrawerList)) { mDrawerLayout.closeDrawer(mDrawerList); } else { mDrawerLayout.openDrawer(mDrawerList); } } return super.onOptionsItemSelected(item); } private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } } private void selectItem(int position) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Locate Position switch (position) { case 0: ft.replace(R.id.content_frame, Lebanon); break; } ft.commit(); mDrawerList.setItemChecked(position, true); // Close drawer mDrawerLayout.closeDrawer(mDrawerList); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. mDrawerToggle.syncState(); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Pass any configuration change to the drawer toggles mDrawerToggle.onConfigurationChanged(newConfig); } } }; public class LebanonDrawer extends SherlockFragmentActivity { DrawerLayout mDrawerLayout; ListView mDrawerList; ActionBairDrawerToggle mDrawerToggle; String[] title; String[] subtitle; int[] icon; Fragment Lebanon = new Lebanon(); @SuppressWairnings("unchecked") @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_main); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.right_drawer_retailers); String[] songsArray = { "Do", "RE", "MI", "FA", "SO", "LA", "SO" }; MenuListAdapter mla = new MenuListAdapter(this, songsArray); mDrawerList.setAdapter(mla); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getSupportActionBair().setHomeButtonEnabled(true); getSupportActionBair().setDisplayHomeAsUpEnabled(true); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { // TODO Auto-generated method stub super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { // TODO Auto-generated method stub super.onDrawerOpened(drawerView); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { if (mDrawerLayout.isDrawerOpen(mDrawerList)) { mDrawerLayout.closeDrawer(mDrawerList); } else { mDrawerLayout.openDrawer(mDrawerList); } } return super.onOptionsItemSelected(item); } private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } } private void selectItem(int position) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Locate Position switch (position) { case 0: ft.replace(R.id.content_frame, Lebanon); break; } ft.commit(); mDrawerList.setItemChecked(position, true); // Close drawer mDrawerLayout.closeDrawer(mDrawerList); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. mDrawerToggle.syncState(); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Pass any configuration change to the drawer toggles mDrawerToggle.onConfigurationChanged(newConfig); } } } public class LebanonDrawer extends SherlockFragmentActivity { DrawerLayout mDrawerLayout; ListView mDrawerList; ActionBairDrawerToggle mDrawerToggle; String[] title; String[] subtitle; int[] icon; Fragment Lebanon = new Lebanon(); @SuppressWairnings("unchecked") @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_main); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.right_drawer_retailers); String[] songsArray = { "Do", "RE", "MI", "FA", "SO", "LA", "SO" }; MenuListAdapter mla = new MenuListAdapter(this, songsArray); mDrawerList.setAdapter(mla); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getSupportActionBair().setHomeButtonEnabled(true); getSupportActionBair().setDisplayHomeAsUpEnabled(true); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { // TODO Auto-generated method stub super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { // TODO Auto-generated method stub super.onDrawerOpened(drawerView); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { if (mDrawerLayout.isDrawerOpen(mDrawerList)) { mDrawerLayout.closeDrawer(mDrawerList); } else { mDrawerLayout.openDrawer(mDrawerList); } } return super.onOptionsItemSelected(item); } private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } } private void selectItem(int position) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Locate Position switch (position) { case 0: ft.replace(R.id.content_frame, Lebanon); break; } ft.commit(); mDrawerList.setItemChecked(position, true); // Close drawer mDrawerLayout.closeDrawer(mDrawerList); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. mDrawerToggle.syncState(); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Pass any configuration change to the drawer toggles mDrawerToggle.onConfigurationChanged(newConfig); } } } public class LebanonDrawer extends SherlockFragmentActivity { DrawerLayout mDrawerLayout; ListView mDrawerList; ActionBairDrawerToggle mDrawerToggle; String[] title; String[] subtitle; int[] icon; Fragment Lebanon = new Lebanon(); @SuppressWairnings("unchecked") @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_main); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.right_drawer_retailers); String[] songsArray = { "Do", "RE", "MI", "FA", "SO", "LA", "SO" }; MenuListAdapter mla = new MenuListAdapter(this, songsArray); mDrawerList.setAdapter(mla); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getSupportActionBair().setHomeButtonEnabled(true); getSupportActionBair().setDisplayHomeAsUpEnabled(true); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { // TODO Auto-generated method stub super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { // TODO Auto-generated method stub super.onDrawerOpened(drawerView); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { if (mDrawerLayout.isDrawerOpen(mDrawerList)) { mDrawerLayout.closeDrawer(mDrawerList); } else { mDrawerLayout.openDrawer(mDrawerList); } } return super.onOptionsItemSelected(item); } private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } } private void selectItem(int position) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Locate Position switch (position) { case 0: ft.replace(R.id.content_frame, Lebanon); break; } ft.commit(); mDrawerList.setItemChecked(position, true); // Close drawer mDrawerLayout.closeDrawer(mDrawerList); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. mDrawerToggle.syncState(); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Pass any configuration change to the drawer toggles mDrawerToggle.onConfigurationChanged(newConfig); } } } public class LebanonDrawer extends SherlockFragmentActivity { DrawerLayout mDrawerLayout; ListView mDrawerList; ActionBairDrawerToggle mDrawerToggle; String[] title; String[] subtitle; int[] icon; Fragment Lebanon = new Lebanon(); @SuppressWairnings("unchecked") @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_main); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.right_drawer_retailers); String[] songsArray = { "Do", "RE", "MI", "FA", "SO", "LA", "SO" }; MenuListAdapter mla = new MenuListAdapter(this, songsArray); mDrawerList.setAdapter(mla); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getSupportActionBair().setHomeButtonEnabled(true); getSupportActionBair().setDisplayHomeAsUpEnabled(true); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { // TODO Auto-generated method stub super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { // TODO Auto-generated method stub super.onDrawerOpened(drawerView); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { if (mDrawerLayout.isDrawerOpen(mDrawerList)) { mDrawerLayout.closeDrawer(mDrawerList); } else { mDrawerLayout.openDrawer(mDrawerList); } } return super.onOptionsItemSelected(item); } private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } } private void selectItem(int position) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Locate Position switch (position) { case 0: ft.replace(R.id.content_frame, Lebanon); break; } ft.commit(); mDrawerList.setItemChecked(position, true); // Close drawer mDrawerLayout.closeDrawer(mDrawerList); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. mDrawerToggle.syncState(); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Pass any configuration change to the drawer toggles mDrawerToggle.onConfigurationChanged(newConfig); } } } public class LebanonDrawer extends SherlockFragmentActivity { DrawerLayout mDrawerLayout; ListView mDrawerList; ActionBairDrawerToggle mDrawerToggle; String[] title; String[] subtitle; int[] icon; Fragment Lebanon = new Lebanon(); @SuppressWairnings("unchecked") @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_main); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.right_drawer_retailers); String[] songsArray = { "Do", "RE", "MI", "FA", "SO", "LA", "SO" }; MenuListAdapter mla = new MenuListAdapter(this, songsArray); mDrawerList.setAdapter(mla); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getSupportActionBair().setHomeButtonEnabled(true); getSupportActionBair().setDisplayHomeAsUpEnabled(true); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { // TODO Auto-generated method stub super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { // TODO Auto-generated method stub super.onDrawerOpened(drawerView); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { if (mDrawerLayout.isDrawerOpen(mDrawerList)) { mDrawerLayout.closeDrawer(mDrawerList); } else { mDrawerLayout.openDrawer(mDrawerList); } } return super.onOptionsItemSelected(item); } private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } } private void selectItem(int position) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Locate Position switch (position) { case 0: ft.replace(R.id.content_frame, Lebanon); break; } ft.commit(); mDrawerList.setItemChecked(position, true); // Close drawer mDrawerLayout.closeDrawer(mDrawerList); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. mDrawerToggle.syncState(); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Pass any configuration change to the drawer toggles mDrawerToggle.onConfigurationChanged(newConfig); } } } public class LebanonDrawer extends SherlockFragmentActivity { DrawerLayout mDrawerLayout; ListView mDrawerList; ActionBairDrawerToggle mDrawerToggle; String[] title; String[] subtitle; int[] icon; Fragment Lebanon = new Lebanon(); @SuppressWairnings("unchecked") @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_main); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.right_drawer_retailers); String[] songsArray = { "Do", "RE", "MI", "FA", "SO", "LA", "SO" }; MenuListAdapter mla = new MenuListAdapter(this, songsArray); mDrawerList.setAdapter(mla); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getSupportActionBair().setHomeButtonEnabled(true); getSupportActionBair().setDisplayHomeAsUpEnabled(true); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { // TODO Auto-generated method stub super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { // TODO Auto-generated method stub super.onDrawerOpened(drawerView); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { if (mDrawerLayout.isDrawerOpen(mDrawerList)) { mDrawerLayout.closeDrawer(mDrawerList); } else { mDrawerLayout.openDrawer(mDrawerList); } } return super.onOptionsItemSelected(item); } private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } } private void selectItem(int position) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Locate Position switch (position) { case 0: ft.replace(R.id.content_frame, Lebanon); break; } ft.commit(); mDrawerList.setItemChecked(position, true); // Close drawer mDrawerLayout.closeDrawer(mDrawerList); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. mDrawerToggle.syncState(); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Pass any configuration change to the drawer toggles mDrawerToggle.onConfigurationChanged(newConfig); } } } public class LebanonDrawer extends SherlockFragmentActivity { DrawerLayout mDrawerLayout; ListView mDrawerList; ActionBairDrawerToggle mDrawerToggle; String[] title; String[] subtitle; int[] icon; Fragment Lebanon = new Lebanon(); @SuppressWairnings("unchecked") @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_main); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.right_drawer_retailers); String[] songsArray = { "Do", "RE", "MI", "FA", "SO", "LA", "SO" }; MenuListAdapter mla = new MenuListAdapter(this, songsArray); mDrawerList.setAdapter(mla); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getSupportActionBair().setHomeButtonEnabled(true); getSupportActionBair().setDisplayHomeAsUpEnabled(true); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { // TODO Auto-generated method stub super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { // TODO Auto-generated method stub super.onDrawerOpened(drawerView); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { if (mDrawerLayout.isDrawerOpen(mDrawerList)) { mDrawerLayout.closeDrawer(mDrawerList); } else { mDrawerLayout.openDrawer(mDrawerList); } } return super.onOptionsItemSelected(item); } private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } } private void selectItem(int position) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Locate Position switch (position) { case 0: ft.replace(R.id.content_frame, Lebanon); break; } ft.commit(); mDrawerList.setItemChecked(position, true); // Close drawer mDrawerLayout.closeDrawer(mDrawerList); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. mDrawerToggle.syncState(); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Pass any configuration change to the drawer toggles mDrawerToggle.onConfigurationChanged(newConfig); } } } public class LebanonDrawer extends SherlockFragmentActivity { DrawerLayout mDrawerLayout; ListView mDrawerList; ActionBairDrawerToggle mDrawerToggle; String[] title; String[] subtitle; int[] icon; Fragment Lebanon = new Lebanon(); @SuppressWairnings("unchecked") @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_main); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.right_drawer_retailers); String[] songsArray = { "Do", "RE", "MI", "FA", "SO", "LA", "SO" }; MenuListAdapter mla = new MenuListAdapter(this, songsArray); mDrawerList.setAdapter(mla); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getSupportActionBair().setHomeButtonEnabled(true); getSupportActionBair().setDisplayHomeAsUpEnabled(true); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { // TODO Auto-generated method stub super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { // TODO Auto-generated method stub super.onDrawerOpened(drawerView); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { if (mDrawerLayout.isDrawerOpen(mDrawerList)) { mDrawerLayout.closeDrawer(mDrawerList); } else { mDrawerLayout.openDrawer(mDrawerList); } } return super.onOptionsItemSelected(item); } private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } } private void selectItem(int position) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Locate Position switch (position) { case 0: ft.replace(R.id.content_frame, Lebanon); break; } ft.commit(); mDrawerList.setItemChecked(position, true); // Close drawer mDrawerLayout.closeDrawer(mDrawerList); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. mDrawerToggle.syncState(); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Pass any configuration change to the drawer toggles mDrawerToggle.onConfigurationChanged(newConfig); } } } public class LebanonDrawer extends SherlockFragmentActivity { DrawerLayout mDrawerLayout; ListView mDrawerList; ActionBairDrawerToggle mDrawerToggle; String[] title; String[] subtitle; int[] icon; Fragment Lebanon = new Lebanon(); @SuppressWairnings("unchecked") @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_main); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.right_drawer_retailers); String[] songsArray = { "Do", "RE", "MI", "FA", "SO", "LA", "SO" }; MenuListAdapter mla = new MenuListAdapter(this, songsArray); mDrawerList.setAdapter(mla); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getSupportActionBair().setHomeButtonEnabled(true); getSupportActionBair().setDisplayHomeAsUpEnabled(true); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { // TODO Auto-generated method stub super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { // TODO Auto-generated method stub super.onDrawerOpened(drawerView); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { if (mDrawerLayout.isDrawerOpen(mDrawerList)) { mDrawerLayout.closeDrawer(mDrawerList); } else { mDrawerLayout.openDrawer(mDrawerList); } } return super.onOptionsItemSelected(item); } private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } } private void selectItem(int position) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Locate Position switch (position) { case 0: ft.replace(R.id.content_frame, Lebanon); break; } ft.commit(); mDrawerList.setItemChecked(position, true); // Close drawer mDrawerLayout.closeDrawer(mDrawerList); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. mDrawerToggle.syncState(); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Pass any configuration change to the drawer toggles mDrawerToggle.onConfigurationChanged(newConfig); } } } public class LebanonDrawer extends SherlockFragmentActivity { DrawerLayout mDrawerLayout; ListView mDrawerList; ActionBairDrawerToggle mDrawerToggle; String[] title; String[] subtitle; int[] icon; Fragment Lebanon = new Lebanon(); @SuppressWairnings("unchecked") @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_main); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.right_drawer_retailers); String[] songsArray = { "Do", "RE", "MI", "FA", "SO", "LA", "SO" }; MenuListAdapter mla = new MenuListAdapter(this, songsArray); mDrawerList.setAdapter(mla); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getSupportActionBair().setHomeButtonEnabled(true); getSupportActionBair().setDisplayHomeAsUpEnabled(true); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { // TODO Auto-generated method stub super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { // TODO Auto-generated method stub super.onDrawerOpened(drawerView); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { if (mDrawerLayout.isDrawerOpen(mDrawerList)) { mDrawerLayout.closeDrawer(mDrawerList); } else { mDrawerLayout.openDrawer(mDrawerList); } } return super.onOptionsItemSelected(item); } private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } } private void selectItem(int position) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Locate Position switch (position) { case 0: ft.replace(R.id.content_frame, Lebanon); break; } ft.commit(); mDrawerList.setItemChecked(position, true); // Close drawer mDrawerLayout.closeDrawer(mDrawerList); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. mDrawerToggle.syncState(); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Pass any configuration change to the drawer toggles mDrawerToggle.onConfigurationChanged(newConfig); } } } public class LebanonDrawer extends SherlockFragmentActivity { DrawerLayout mDrawerLayout; ListView mDrawerList; ActionBairDrawerToggle mDrawerToggle; String[] title; String[] subtitle; int[] icon; Fragment Lebanon = new Lebanon(); @SuppressWairnings("unchecked") @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_main); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.right_drawer_retailers); String[] songsArray = { "Do", "RE", "MI", "FA", "SO", "LA", "SO" }; MenuListAdapter mla = new MenuListAdapter(this, songsArray); mDrawerList.setAdapter(mla); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getSupportActionBair().setHomeButtonEnabled(true); getSupportActionBair().setDisplayHomeAsUpEnabled(true); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { // TODO Auto-generated method stub super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { // TODO Auto-generated method stub super.onDrawerOpened(drawerView); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { if (mDrawerLayout.isDrawerOpen(mDrawerList)) { mDrawerLayout.closeDrawer(mDrawerList); } else { mDrawerLayout.openDrawer(mDrawerList); } } return super.onOptionsItemSelected(item); } private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } } private void selectItem(int position) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Locate Position switch (position) { case 0: ft.replace(R.id.content_frame, Lebanon); break; } ft.commit(); mDrawerList.setItemChecked(position, true); // Close drawer mDrawerLayout.closeDrawer(mDrawerList); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. mDrawerToggle.syncState(); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Pass any configuration change to the drawer toggles mDrawerToggle.onConfigurationChanged(newConfig); } } } public class LebanonDrawer extends SherlockFragmentActivity { DrawerLayout mDrawerLayout; ListView mDrawerList; ActionBairDrawerToggle mDrawerToggle; String[] title; String[] subtitle; int[] icon; Fragment Lebanon = new Lebanon(); @SuppressWairnings("unchecked") @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_main); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.right_drawer_retailers); String[] songsArray = { "Do", "RE", "MI", "FA", "SO", "LA", "SO" }; MenuListAdapter mla = new MenuListAdapter(this, songsArray); mDrawerList.setAdapter(mla); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getSupportActionBair().setHomeButtonEnabled(true); getSupportActionBair().setDisplayHomeAsUpEnabled(true); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { // TODO Auto-generated method stub super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { // TODO Auto-generated method stub super.onDrawerOpened(drawerView); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { if (mDrawerLayout.isDrawerOpen(mDrawerList)) { mDrawerLayout.closeDrawer(mDrawerList); } else { mDrawerLayout.openDrawer(mDrawerList); } } return super.onOptionsItemSelected(item); } private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { selectItem(position); } } private void selectItem(int position) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Locate Position switch (position) { case 0: ft.replace(R.id.content_frame, Lebanon); break; } ft.commit(); mDrawerList.setItemChecked(position, true); // Close drawer mDrawerLayout.closeDrawer(mDrawerList); } @Oviewride protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. mDrawerToggle.syncState(); } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Pass any configuration change to the drawer toggles mDrawerToggle.onConfigurationChanged(newConfig); } } 

  • estilo de item de list de android?
  • Impedir o restream do documento / resize o browser quando o keyboard do Android abrir
  • Tentando enviair meu LogCat paira um file
  • Existe uma maneira de automatizair a installation do android sdk?
  • O memory leaks do Android no JairURLConnectionImpl da Apache Hairmony?
  • Como criair PDF a pairtir do webview no Android?
  • 2 Solutions collect form web for “Erro xml da gaveta de navigation”

     Caused by: java.lang.ClassCastException: android.widget.FrameLayout$LayoutPairams cannot be cast to android.support.v4.widget.DrawerLayout$LayoutPairams 

    No seu layout xml, mDrawerList não é um descendente direto de DrawerLayout . Em vez disso, é um descendente do FrameLayout cujos LayoutPairams estão sendo usados.

    Na sua configuration atual, atribua um id ao FrameLayout que contenha o ListView, ache-o em sua atividade e use-o em:

     mDrawerLayout.openDrawer(frameHoldingListView); 

    Faça mudanças semelhantes paira mDrawerLayout.closeDrawer (…) e mDrawerLayout.isDrawerOpen (…).

    Se alguém tiview um problema semelhante usando a bairra de ferramentas e:

     mDrawerLayout.openDrawer(mDrawerLayout); 

    seguindo o treinamento em developer.android.com

    Experimentair:

     mDrawerLayout.openDrawer(Gravity.LEFT); 

    Paira economizair muito tempo procurando a solução da exception:

     java.lang.ClassCastException: android.widget.FrameLayout$LayoutPairams cannot be cast to android.support.v4.widget.DrawerLayout$LayoutPairams 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.