Android examples for User Interface:ActionBar Title
set Title for ActionBar using SpannableString
import android.annotation.TargetApi; import android.app.ActionBar; import android.os.Build; import android.text.SpannableString; public class Main{ public static void setTitle(android.support.v7.app.ActionBar actionBar, SpannableString spannableString) { // BUGFIX // @see http://stackoverflow.com/questions/7658725/android-java-lang-illegalargumentexception-invalid-payload-item-type if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN && Build.MANUFACTURER.toUpperCase().equals("LGE")) { actionBar.setTitle(spannableString.toString()); } else {/*from w w w. j av a 2s .c o m*/ actionBar.setTitle(spannableString); } } public static void setTitle(android.support.v7.app.ActionBar actionBar, CharSequence charSequence) { actionBar.setTitle(charSequence.toString()); } @TargetApi(11) public static void setTitle(ActionBar actionBar, SpannableString spannableString) { // BUGFIX // @see http://stackoverflow.com/questions/7658725/android-java-lang-illegalargumentexception-invalid-payload-item-type if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN && Build.MANUFACTURER.toUpperCase().equals("LGE")) { actionBar.setTitle(spannableString.toString()); } else { actionBar.setTitle(spannableString); } } @TargetApi(11) public static void setTitle(ActionBar actionBar, CharSequence charSequence) { actionBar.setTitle(charSequence.toString()); } }