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 did 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 "\?".
Related
I have tried all the options which are available i.e. textNoSuggestions, textFilter, textMultiline. But they didn't work for me. So, after using all these I even tried to set inputType from java file but even that didn't work either.
I have my EditText in ConstraintLayout.
Thanks in advance.
You can use below inputType and it will work -
android:inputType="textVisiblePassword"
Hope this will help you.
Looks like this is not autosuggestion but autofill. Make sure you've not set android:autofillHints and remove it if it is set.
You can also try to set android:importantForAutofill="no"
In my application I have a quiz page..
It have questions and answer.. Each question have question number..
Sample question:
Which one of the following would make a suitable inert electrode in
the electrolysis of sodium sulfate solution?
But I want to give some space for next line to align properly..
Which one of the following would make a suitable inert electrode in
the electrolysis of sodium sulfate solution?
Currently I acheive with two textviews (one for number another for question) within linearlayout.
My question:
This alignment possible with same textview?
You can try the android:gravity="center". This might look better.
On applying it, the text would be looking like
Q1: This will be the line of your question and
this will be the second line.
you can use two textviews one for the number of the question and the other for the question and answer just seperate them with a "\n"
or add tab space with "\t" before the answer , both should work ,
much luck.
You can try '\t' it make space but in android text align based on device width.
For example:
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="1.Which one of the following would make a
suitable inert electrode in \t \t \t the electrolysis of sodium sulfate solution?"/>
I am learning Android and want to be able to add line comments to my XML so I can remind myself what things are doing.
Is there an accepted practice for this, or is it possible in Android Studio? I recall reading that comments in XML are hard, so I wanted to know if that was also considered true here.
As mentioned above you can comment in XML just like this:
<!-- Comment -->
But in android studio you can very easily toggle comment just by selecting what you want to comment and then pressing:
CTRL + /
This not only for XML but also for your java code for example.
It is indeed possible. I'm not sure if there is an accepted practice, but you can accomplish leaving a comment like this
<!-- comment goes here -->
Same as in all XML applications:
Just use <!-- ... --> to comment.
Comments in XML aren't too tough. You have to do it like this:
For example
<!-- This is a comment -->
Please don't hesitate to ask for anymore help. The above should work in android studio.
If you are using a Mac then command is command(button which looks like Windows start button ) + /
If you are on Windows then it is
Cntrl + /
Try and see if it works
In Android Studio DOLPHIN version I have tried using the
and the file does NOT like it. It produces errors when used.
I don't know about XML files much, but this AndroidManifest.xml file does not like this. Any other tips that might work? This file is error free before the comment line is added.
I am writing an view where I need to display superscript data. I am following this to achieve this.
Along this is there any way to change font size(in number) of superscript text.
EDIT
Commanware suggested link work great, except one thing. I need superscript bit above of base text. I'm updating image for same, please refer. I'm using same code with mention in reference code.
Here either can go for separate text view could be second priority solution. Any suggestion !
try this one this is working code:
((TextView)findViewById(R.id.text)).setText(Html.fromHtml("04:30<sup><small>pm</small></sup>"));
you cant pass text size in numbers, yo have to change the size to string :
<font size="3" color="red">This is some text!</font>
Use this Code :
((TextView)findViewById(R.id.text)).setText(Html.fromHtml("your Text <sup style="font-size:5(yourfontsize);">subscript</sup>"));
Try this and Let me know :)
This property makes
"short and very-long-word"
to
"short and"
. But I want to have smth. like
"short and very-lon..."
Right now I truncate the String in Java code. However, thats based on the number of characters and not the actual length of the link. So, the result isn't very nice.
String title;
if(model.getOrganization().length() > 19) {
title = model.getText().substring(0, 15).trim() + "…";
} else {
title = model.getText();
}
((TextView) findViewById(R.id.TextViewTitle)).setText(title);
Update
Just noticed, this property actually adds "..." in a few cases. But not in all of them:
12345678901234567890 becomes
"12345678901234..."
However,
"1234567890 1234567890"
becomes "1234567890" and not
"1234567890 123..."
Update 2
Now it really gets funky! I just set singleLine=true and removed maxLine (The bug appears with and without setting ellipsize attribute)...
This is a screenshot take from Motorola Milestone with android 2.1 update 1. Same happens on HTC Desire with the same android version
Update 3
Now I use android:ellipsize="marquee". That seems to be the only properly working setting. It's also only moving, when focused. I see it in many other apps also. I guess its common practise.
If it's for a single line try this:
android:ellipsize="end"
android:maxLines="1"
android:scrollHorizontally="true"
android:singleLine="true"
It worked for me.
I had a similar problem and setting this property to the TextView helped:
android:singleLine="true"
Also, I was using a RelativeLayout so I limited the space the TextView could take by setting a left margin to a button to the right of the TextView, so that the text cannot expand further and is forced to truncate its content.
Maybe it's not the solution to your problem, but it helped me in a similar situation.
See my update 3. The workaround was using " marquee". I have seen many apps doing that at this time.
Now, with new versions of Android this feature is most likely fixed and will work as expected. (my guess)
Maybe you could take a look at how the private Ellipsizer class used by the OS works and modify it for your app?
Edit: Here's a working link - http://androidxref.com/5.1.0_r1/xref/frameworks/base/core/java/android/text/Layout.java#1830