Changing Navigation drawer icon on action bar android

To replace the drawer indicator icon with your own drawable(non animated) using the v7 ActionBarDrawerToggle, you can do the following: //After instantiating your ActionBarDrawerToggle mDrawerToggle.setDrawerIndicatorEnabled(false); Drawable drawable = ResourcesCompat.getDrawable(getResources(), R.drawable.your_custom_icon, getActivity().getTheme()); mDrawerToggle.setHomeAsUpIndicator(drawable); mDrawerToggle.setToolbarNavigationClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mDrawerLayout.isDrawerVisible(GravityCompat.START)) { mDrawerLayout.closeDrawer(GravityCompat.START); } else { mDrawerLayout.openDrawer(GravityCompat.START); } } });

How to create button in Action bar in android [duplicate]

In your activity class, override the following methods if they are not there by default: // create an action bar button @Override public boolean onCreateOptionsMenu(Menu menu) { // R.menu.mymenu is a reference to an xml file named mymenu.xml which should be inside your res/menu directory. // If you don’t have res/menu, just create a directory … Read more

android.support.v7 with `ActionBarActivity` no menu shows

Try pressing the MENU button on your device or emulator, and see if they appear in the overflow. If they do, then the problem is that your <menu> XML needs to change. Menu XML that works with ActionBarSherlock and the native API Level 11+ action bar will not work with the AppCompat action bar backport. … Read more

How to resume activity instead of restart when going “up” from action bar

Should’ve added as an answer instead of a comment.. but here you go so you can accept if you want so others can see if necessary. https://stackoverflow.com/a/16147110/3286163 Basically, to summarize the android will always recreate the activity unless you specify it not to with android:launchMode=”singleTop” Note: it will not work if the returning activity is … Read more

display view on top of action bar

I was trying to achieve something else but I needed a solution similar to this. I needed to draw an opaque layer covering the whole screen, even the action bar–sort of like a dialog. I did so this way: ViewGroup vg = (ViewGroup)(getWindow().getDecorView().getRootView()); vg.addView(myNewView, params); this can be used to draw anything anywhere on the … Read more

ActionBar – custom view with centered ImageView, Action Items on sides

If you want imageview in Center of ActionBar then use: just replace getActionBar(); to getSupportActionBar(); in below code public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ActionBar actionBar = getActionBar(); actionBar.setCustomView(R.layout.actionbar_custom_view_home); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowCustomEnabled(true); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } your actionbar_custom_view_home.xml <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:gravity=”center” … Read more

How can I force the Action Bar to be at the bottom in ICS?

I’ve tried adding the line in the application manifest, as described in the docs, but haven’t got it working thus far. It worked for me in this sample project. Here is the manifest: <?xml version=”1.0″ encoding=”utf-8″?> <manifest package=”com.commonsware.android.actionbarbc” xmlns:android=”http://schemas.android.com/apk/res/android”> <application android:hardwareAccelerated=”true” android:icon=”@drawable/cw” android:label=”@string/app_name”> <activity android:label=”@string/app_name” android:name=”.InflationDemo” android:uiOptions=”splitActionBarWhenNarrow”> <intent-filter> <action android:name=”android.intent.action.MAIN” /> <category android:name=”android.intent.category.LAUNCHER” /> </intent-filter> … Read more

How to set active item in the Action Bar drop-down navigation?

I just found that function. It is setSelectedNavigationItem(int position). Set the selected navigation item in list or tabbed navigation modes. Example: actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks(adapter, this); actionBar.setSelectedNavigationItem(position);