Rishi
Rishi

Reputation: 3539

custom tab title in android

i am setting custom title in my tab activity like this

    boolean customTitleSupported;
    customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
  //  customTitleSupported = false;

  //check for custom title supported feature   
    if(customTitleSupported == true) {
        customTitleBar();
    } else {
        requestWindowFeature(Window.FEATURE_LEFT_ICON);
        String title = prefManager.getTitle();
        setTitle(NAME + " " + title);
    }
    //Set contentview of activity  
    setContentView(R.layout.tabactivity);  

    if(customTitleSupported == false){
        setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.logo);
    }

Everything is working fine.But when i make customTitleSupported to FALSE to check if custom title support is not there in sdk then it should call normal setTitle() function. But if i do this customTitleSupported = false; i am getting following error

android.util.AndroidRuntimeException: You cannot combine custom titles with other title 

features

i am not clearly understanding the problem if custom title is not supported why i cannot request for other title features.If i doest not request for custom title then else part of setting icon and title works but i want to handle both conditions together.

Thanks

Upvotes: 0

Views: 3424

Answers (1)

manelizzard
manelizzard

Reputation: 1058

You canot use other title features with FEATURE_CUSTOM_TITLE, and you cannot turn off a feature once requested: check doc

You just have to use setFeatureInt(int featureId, int value) and provide a layout resource ID at "value". Check this example: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/CustomTitle.html

Upvotes: 3

Related Questions