Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
213 views
in Technique[技术] by (71.8m points)

android - cannot combine custom titles with other title features

I am getting this error when calling the setContentView() after

    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.maintitlebar);

The code is in the onCreate() for my class which extends ListActivity. My manifest XML file shows the default AppTheme for the application:

     android:theme="@style/AppTheme"

I have updated styles.xml to be:

<resources>
   <style name="AppTheme" parent="android:Theme.Light" >
    <item name="android:windowNoTitle">true</item>
   </style>   
</resources>

This seems to be in accordance with the main posts on this error message. I have also cleaned the build, yet I am still getting the above error message. Has anybody any idea what is causing the clash?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I had a similar problem that drove me insane: I have 2 versions of the same app using a shared library project as their common code (over 95% of each app is made of that shared library project): One runs fine, without any problem whatsoever. The other crashes upon start with the same error message & symptoms you describe:

You cannot combine custom titles with other title features

The layout XML files are common as well! So, I couldn't find any explanation for this weird problem.

After much brainstorming between me, myself and I, I discovered that the only difference between the two apps is that the one that runs fine has this in its AndroidManifest.xml:

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="7" />

And the one that crashes has this in its AndroidManifest.xml:

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="13" />

So, you see, the Android UI is touted as being a 4th-generation UI framework, in which the UI is declarative and independently themed, but at the end of the day it's all the same st: Developing in C (for example) for Microsoft Windows is no more time consuming than developing in Java for the Android because the Android development framework is full of landmines like this in which the compiler won't tell you anything at compile time, and the thrown exception won't tell you either. Instead, you have to rely on **luck finding that little snippet of documentation (that may or may not exist), providing you with a hint as to where to look for the root cause of the problem.

I hope that this information will be helpful to many who experience the same problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...