Action Bar icon as up enabled not the title

How to make app icon as up enabled in actionbarsherlock (not the title only icon) like in whats app.

  • Setting setChunkedStreamingMode in HttpURLConnection fails to deliver data to server
  • Is possible use drawable-mdpi-fr, drawable-hdpi-fr, drawable-ldpi-fr, for localization with different resolutions
  • ListView divider not showing in Android 5
  • Android checkMarkGravity attribute of CheckedTextView (api 21 )
  • get Primary Email Account of android phone
  • WindowActivityBar=false not working
  • Related posts:

    Turn off screen on Android
    How to keep an Android app running indefinitely?
    Prevent word from being broken in TextView
    How long for an app to be approved for Amazon AppStore?
    How to set permissions in broadcast sender and receiver in android
    hidden backstack fragments re-shown on configuration change
  • write c# implementation of abstract class inline?
  • Android: launch a custom Preference from a PreferenceActivity
  • What is a binder callback on Android?
  • Get Bitmap from ImageView loaded with Picasso
  • Hide Mouse Pointer on Android
  • Android, simple-xml, how to declare a list of elements?
  • 4 Solutions collect form web for “Action Bar icon as up enabled not the title”

    The title is clickable together with the icon since Android 4.2.2. WhatsApp uses a custom view to display a two line title. This disables the title click along the way. You can do it the same way:

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setCustomView(R.layout.ab_title);
    
    TextView title = (TextView) findViewById(android.R.id.text1);
    title.setText("Title");
    

    /res/layout/ab_title.xml:

    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@android:id/text1"
        style="@style/TextAppearance.Sherlock.Widget.ActionBar.Title"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:ellipsize="end"
        android:gravity="center_vertical" />
    

    Add the following to your onCreate method:

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    

    and define the following override method in your activity:

    @Override
    public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
        switch (item.getItemId()) {
        case android.R.id.home:
            onBackPressed();
            break;
        default:
            return super.onOptionsItemSelected(item);
        }
        return true;
    }
    

    My friend, I think this is Android version/build “feature”, because I have two devices, (Nexus S and Nexus 7) (Android 4.1.2 and Android 4.2.2) and I am deploying the app I am developing on both devices, same exact code, on Nexus S the icon is “up”, on Nexus 7 the icon and title are both “up”.

    make sure your android:minSdkVersion=”11″ which could be seen in the manifest file, Up icon has been included from APK 11. Add the following to your onCreate method For home page put getActionBar().setDisplayHomeAsUpEnabled(false); make sure it false and on other activities you keep it enabled i,e “true”. i have made a small sample plz try the below link which may be help you just import into your work space

    http://www.mediafire.com/?hktdvts7yyduwv1

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.