开发者

Set button text to question mark

I need to set a button's text to just ?.

I'm happy to do it via Java, but would rather do it via the XML.

Is it possible?

I've tried android:text="?" and android:text="?" but it did not work.

Then I set one of the string resources to ?, and when that d开发者_如何学Pythonid not work I set it to ?referenced that but it doesn't work!

How do I set the button caption to ? using XML?


You need to escape the question mark...

android:text="\?"


Write "\?" Intead normal or ASCII form.


You try this way.. just give space before or after ? this will work i think..

android:text=" ?" or android:text="? "


give the space before writing the ?(android:text=" ?")...it's working fine.other wise. you have to add image to button(android:background="@drawable/image"). or u need to take imagebutton add question mark image to it.


Part of your problem is that in some versions of the Eclipse Android Layout Editor, it will freak out with a question mark as its text on a button. I submitted a bug report, and after a year I received a note saying that the bug is fixed.

So make sure you have version 21.1 or greater of the API to get the bug fix.

See my question about this: Android Layout Editor Freaks Out on Question Mark

Hope this helps.


Try using a \ before the question mark like this "\?".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜