This is strange, yet I see it all the time as I have lots of reasons to display just a simple question mark in this app.

When editing with the Eclipse graphical layout editor, everything is fine...until I tell a TextEdit or a Button to display just a question mark. Here's my code:

<?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="fill_parent"
    android:orientation="vertical"
    >
    <TextView
        android:id="@+id/test_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/question_mark" />
</LinearLayout>

And the string is defined in res/values/strings.xml. The relevant line is:

<string name="question_mark">\u003f</string>

The error message I get is:

Missing styles. Is the correct theme chosen for this layout? Use the Theme combo box above the layout to choose a different layout, or fix the theme style references.

Couldn't find theme resource for the current theme

Change the text, and the error message goes away.

You can see that in my struggles, I'm even trying to use the unicode version of a question mark. And yes, \? doesn't work either.

Note that this only happens when the graphical layout editor is set to API 7 or greater.

Now the graphical layout editor displays the question mark properly, and the emulator and my phone display the question mark without any problems. I'm just annoyed with the error message taking up 1/4 of my screen for all my layouts (and obscuring other error messages that may crop up).

Any suggestions?

有帮助吗?

解决方案 3

Wow, I entered a bug report...[time marches on]...finally, I get a few emails as the Google team starts to look at it.

Today, I received some good news. It looks like the bug has been fixed (and they found a few related bugs, which have been fixed as well). The fix will be in the next release, Version 21.1 Preview 2. You can read the official details here.

Looking forward to it!

其他提示

First, test this again on the ADT 21 release that shipped today.

If the problem continues, create a sample project that demonstrates the issue, and post it along with step-by-step instructions on the Android issue tracker.

Well, this is a really crappy hack, but it kind of works--if you stand on your head!

You can use the unicode \u00bf as in

    <TextView
    android:id="@+id/test_title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="\u00bf" />

It's not a normal question mark, but it's close enough for a hack and gets that annoying error message out of your hair. And it might even increase the humor quotient of your app!

But PLEASE, if anyone out there has a real fix, post it!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top