Have Android EditText appear to be in focus - android

Would it be possible to have an edit text appear to be in focus but not not actually be in focus. I would like the bright blue underline on two or more of the edit texts in my UI but never have them in focus or have the blinking insertion point. I have tried android:focusable="false" but that makes it grayed out. I'v also tried out a number of other combination but can't seem to find one that works.

Try to use
setSelected(true);
I think it will help
Edit:
To summarize I think you cannot really setSelection on multiple edittext at the same time but you can customize your editext by giving them custom background using selectors so they will look like selected.
You can accomplish it by using these tools that allow quick resources generators.
http://romannurik.github.io/AndroidAssetStudio/

Try this:
<EditText ... >
<requestFocus />
</EditText>
Hope this helps.

Programatically you can "request focus" to your view:
myEditText.requestFocus();
or via xml:
<EditText>
<requestFocus />
</EditText>

Related

Android EditText.setError not working in not focusable

How can I display a text error with setError in an EditText not focusable? It's important that users don't modify this EditText, it'll be modified for the application. Maybe I have another option different than focusable=false?
Now, I have it:
<EditText
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:ems="10"
android:focusable="false"
android:inputType="text"
android:onClick="onClick" />
Thanks a lot!
Finally I think it's not possible to do... Because the first necessity is to block the text, doing it with focusable=false or with a TextView, and it also blocks the functionality setError.
An editText with focusable = false I can get a right drawable (the default red exclamation mark) but without text. For this reason I finally added the text with a Toast.
It's not completelly that I wanted, but it's the most similar.
Thanks for your help!
Just use TextView and if you have an error somewhere then show image with drawableRight.
Here's the example of doingit programmatically: https://stackoverflow.com/a/7380789/3864698

Android - Get auto suggest on top of keyboard for EditText?

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.

What is the small graphic displayed under an EditText called and how can I remove it?

After some pretty thorough googling I still cannot figure out what the the little graphic that's displayed under the text in and EditText View is called. I would also like to remove it either using XML or programmatically. The little graphic is the thing under the cursor in this image: http://1.bp.blogspot.com/-UAuOq0h4Vok/T8reinvaWPI/AAAAAAAABPc/N4yibXd3kZg/s1600/android%2Bedittext%2Btext%2Bchange%2Blistener%2Bexample.jpg . Sorry if this is a dumb question, but without the name of this little graphic feature I can't seem to find out anything about it.
It is the background drawable associated with the edittext. You can change it by manually setting the background to something yourself, such as
<EditText
android:background="#android:color/transparent"
...
/>
Try this..
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/hello"
android:background="#00000000"
/>
if you want transparancy just put 80 before the actual hash code.
#80000000
This will change any colour you want to transparent one.. :)
you probably have in your layout
android:minLines="2"
try to remove it

How to Remove Request Focus from EditText?

I want to remove the blue line from edittext when i touched edittext it appear but i dont know how to remove it. see the picture for more understanding
do it this way
lUserNameEditText.clearFocus();
another way which works for me regarding the border is
lUserNameEditText.setBackgroundColor(0);
Have you tried changing the Layout XML like this
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:background="#00000000"
/>
or do it via code
editTextView.setBackgroundColor(0);
remove requestFocus tag in xml layout so automatically focus will loss

How to make an EditText selectable but not editable on Android Ice Cream Sandwich?

I have a ListView in Activity, and in each item , I insert an EditText for show my text.
I need drag the handle to select text & copy the text, but can not edit text.
On Android ICS, How can I do this?
text.setTextIsSelectable(true) requires API 11. For those using lower API's:
In xml use:
android:inputType="none"
android:textIsSelectable="true"
This will make your EditText uneditable but selectable.
I think you could override the onKeyDown() method, make it do nothing but return true. It should catch the keypresses from the keyboard and negate them before they can go into the text in the EditText.
You might also try setting editable to false like this
android:editable="false"
on the EditText in your xml layout. However I am not certain if this will let you still highlight and copy, but it is worth a shot.
I resolved this problem.
Just set TextView like this:
text.setTextIsSelectable(true);
Althouth android:editable is deprecated and Lint suggests to use inputType, It doesn't seem to work. So android:editable="false"is apparently the best possible solution for all android versions.
<EditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:editable="false"
android:textIsSelectable="true"
tools:ignore="Deprecated" />

Categories

Resources