my navigation drawer doesnot work in android version less than 4.1.
-
public class SwappingClassDashboard extends Activity { DrawerLayout dl; ListView list; ActionBarDrawerToggle toogle; CharSequence title, dtitle; String[] acfservice; MainActivity mainactivity; @Override protected void onCreate(Bundle savedInstanceState) { ActionBar actionbar = getActionBar(); ColorDrawable colorDrawable = new ColorDrawable( Color.parseColor("#0067b4")); actionbar.setBackgroundDrawable(colorDrawable); super.onCreate(savedInstanceState); setContentView(R.layout.swapping_layout); // initializing the value for username and passord field for login mainactivity = new MainActivity(); // end of variable assignment title = dtitle = getTitle(); acfservice = getResources().getStringArray(R.array.acf_array); dl = (DrawerLayout) findViewById(R.id.drawer_layout); list = (ListView) findViewById(R.id.listview); // set a custom shadow that overlays the main content when the drawer // opens dl.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); // set up the drawer's list view with items and click listener list.setAdapter(new ArrayAdapter(this, R.layout.list_drawer, acfservice)); list.setOnItemClickListener(new DrawerItemClickListener()); // enable ActionBar app icon to behave as action to toggle nav drawer ActionBar actionbar1 = getActionBar(); actionbar1.setIcon(R.drawable.acf); actionbar1.setTitle("ACFNepal"); actionbar1.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon toogle = new ActionBarDrawerToggle(this, /* host Activity */ dl, /* DrawerLayout object */ R.drawable.click, /* nav drawer image to replace 'Up' caret */ R.string.onopen, /* "open drawer" description for accessibility */ R.string.onclose /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getActionBar().setTitle(title); invalidateOptionsMenu(); // creates call to // onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(dtitle); invalidateOptionsMenu(); // creates call to // onPrepareOptionsMenu() } }; dl.setDrawerListener(toogle); if (savedInstanceState == null) { selectItem(0); } }