In a a custom list view, I have a textview showing name and emailId. When the name provided is something like A-TestThisString(testA#test.com), the length of displayed area exceeds,
In that case the string is broken at the place of hyphen like
A-
is shown in the list. This is causing lots of problems. I have found one link which talks about solution bellow
topic: "Android: How do i make nonbreakable block in TextView?"
but, I am not able to understand how to use it. Please suggest.
Thanks for your help. I found the answer. use the inputType as email or singleLine=True, it starts working fine.
I used android:inputType="date", no line breaks and hyphen is displayed nicely
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="2-3 4-5"
android:inputType="date"
android:textSize="25sp" />
Related
I know, the question has already been asked many times on this forum, but no answer worked for me...
When I write in one of my EditTexts, the word being written is underlined, and I would like it not to be underlined... I've already seen answers like "You have to change the android:background", or "You have to put the textNoSuggestions attribute in android:inputType"... But I've already done all that - see the code just below - (and I even keep them by default) and it doesn't work.
A really huge thank you to everyone who will take the time to answer this question!
XML EditText :
<EditText
android:id="#+id/editP1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="4dp"
android:autofillHints="username"
android:background="#drawable/background_card"
android:gravity="center_horizontal"
android:hint="#string/player_name"
android:imeOptions="flagNoFullscreen"
android:inputType="textFilter|textNoSuggestions"
android:maxLength="12"
android:padding="4dp"
android:textSize="25sp" />
<!-- The ' android:imeOptions = "flagNoFullscreen" ' was only necessary to show the underline word since my app is always in landscape mode -->
Pictures :
As outlined at Android edittext is underlined when typing, this may be a function of the keyboard in use, rather than the EditText. Without knowing which specific solutions you've tried and have failed (you say no answer worked for you, but don't list things you tried) it is hard to offer a specific suggestion, but I'd suggest the
android:inputType="textVisiblePassword|textNoSuggestions"
option and see if that works. The password should typically prevent the keyboard from suggesting things (since no suggestions are typically useful for passwords).
I'm a newbie to Android and I have looked at similar questions asked by others without a definite answer, since, I think, my problem is a bit different.
I'm using a TextView in my program in which there can be links, text, numbers etc. following is the TextView I'm using.
<TextView
android:id="#+id/viewText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:autoLink="web"
android:linksClickable="false"
android:ellipsize="end"
android:maxLines="7" />
Although this is working for normal texts, the ellipsize does not work whenever links are present in the TextView. I'm using "autoLink" in order to show the user that it is link but had set android:linksClickable to false. Right now, I've added the ellipsize from the code but I want to know whether I can do it from the XML file itself.
Thank you.
I need edittext with auto suggestion turned on.
For this I am using following in xml :
<EditText
android:id="#+id/edt_description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#null"
android:hint="#string/description_album_hint"
android:imeOptions="actionNext"
android:inputType="textCapSentences|textAutoCorrect|textAutoComplete"
android:maxLines="2"
android:minLines="2"
android:singleLine="false"
android:textColor="#color/black"
android:textColorHint="#color/hint_color_light_gray" />
Even if I add "textCapSentences|textAutoCorrect|textAutoComplete" as inputType still there are no suggestions.
Adding Screenshot (this is what I need to implement):
Please help me.
Thanks in advance.
For this purpose you need a subclass of EditText called AutoCompleteTextView. You can find an example here http://developer.android.com/guide/topics/ui/controls/text.html#AutoComplete
If you want to get auto suggestions in top of your keypad, what ever you are following is correct. Additionally you can add android:autoText="true". The suggestion will show you all your previously entered words.
Else if you want to get suggestion for every letter you type, then you can use AutoCompleteTextView.
Here is the code, how you can use this.Ex - AutoCompleteTextView
Got it .....
just removing "textAutoComplete" from "textCapSentences|textAutoCorrect|textAutoComplete" worked for me.
This is more a 'is there a more appropriate way' question as I have found a work around.
Some of my table headers are being picked up as spelling errors and underlined in red. Of course, that is not what I would like to see. I have found that using
android:inputType="textNoSuggestions"
does disable the spell check markings. I find it odd (bug?) that this is necessary as the docs state:
inputType: The type of data being placed in a text field, used to help
an input method decide how to let the user enter text.
and there is no input associated with just textView. So is this the only/more appropriate way of avoiding the spell check and also, is this a bug that it is spell checking non-input fields?
UPDATE: per request this is sample xml
<TextView
android:text="ID#"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:typeface="monospace"
android:textSize="14sp"
android:digits="4"
android:textAlignment="gravity"
android:layout_weight="5"
android:gravity="left"
android:singleLine="true"
android:phoneNumber="true"
android:inputType="textNoSuggestions|none">
</TextView>
First, I would try removing the android:digits, android:phoneNumber, and android:inputType attributes.
All of those are more intended for use with fields that allow input (such as EditTexts). It also doesn't look like you are using the android:digits attribute correctly, as the string you provide defines the only allowable characters.
In essence, this combination of attributes is telling Android that your TextView accepts input in the form of telephone numbers that contain only the number 4, that this TextView doesn't accept input of any type, and Android should not provide spellcheck suggestions.
If you are setting the content of the TextView yourself, there really is no reason to try to restrict the content of the TextView with flags such as android:phoneNumber since you are the one controlling that.
I know this is an old thread but removing the following from content XML worked for me:
android:autoText="true"
On later android studio versions try:
android:autoText="true"
inside of the (or any input) in the xml.
On newer versions try:
android:inputType="textNoSuggestions"
What is the meaning of this warning?
No label views point to this text field with an android:labelFor="#
id/# id/editText1" attribute
Note that the double id (#id/#id) is a problem with the error message text and does not reflect the XML content (which is the correct syntax).
The labelFor is an attribute for accessibility options. You assign this to a label so that if, on a form , user clicks a textedit field , android can know what to read (TalkBack) to user.
The id you assigned to it doesn't seem to be a valid one. why there are two #id in the id? Use ids like this: #id/editText1
I've had the same warning message. It disappeared, when I added a hint to my EditText
android:hint="Some explanation about the input..."
Although I am not familiar with the exact error you have posted. But it definitely sounds like you have done something wrong with the id in the textView. Use id like following in your textView.
android:id="#+id/editText1"
And if you want to set labelFor then use :
android:labelFor="#+id/editText1"
It means that you probably should define a label for this edit text and link them using a labelFor inside that labels definition.
example code:
<TextView
android:id="#+id/my_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:labelFor="#+id/my_editText" <!--the plus sign goes first in the code-->
android:text="I'm a label" />
<EditText
android:id="#id/my_editText" <!--no plus sign if not the first-->
android:layout_width="wrap_content"
android:inputType="text"
android:layout_height="wrap_content" />
and it's not only for text views.
Remove th first '#id/' , use like
android:id="#+id/editText1"
which is the correct format. Keep going.. Best wishes.. :)
I solved it by writing both attributes:
android:id="#+id/editText1"
android:labelFor="#+id/editText1"
Select the editText, go to Properties, then Label for and enter #id/EditText1
If the XML looks correct and you're in a Graphical Layout mode then it's probably using a later version of the Android rendering layout that doesn't support EditText.
In Eclipse and Android Studio there should be a green Android icon with what API version is rendering the layout. Make sure you're using a non W or Wearable API as Android W APIs don't support the EditText element. (EditText is most likely not supported because virtual keyboard space is limited on those devices).
The rendered preview should support EditText in any API 4.X version without a trailing W.