Making not editable EditText component [duplicate] - android

This question already has answers here:
Can we have uneditable text in edittext
(2 answers)
Closed 10 years ago.
I have an edit text. How can I make it non editable from the code.
By giving the tag android:editable we can do in the layout.. But I need to do it in the code...Pls Help

I believe it is as simple as
editText.setEnabled(false);

Refer EDITTEXT
edt.setClickable(false);
edt.setFocusable(false);
***Layout***
<EditText android:id="#+id/edt"
android:layout_width="200px" android:layout_height="wrap_content"
android:text="" android:textSize="18sp" android:maxLength="15">
</EditText>

If you didnt find yet an answer, i have found this in the net:
http://code.google.com/p/android/issues/detail?id=2854

I am using for this problem, this solution:
valueText.setEnabled(false);
valueText.setClickable(false);
valueText.setFocusable(false);
//Just for better text vision
valueText.setTextColor(Color.WHITE);

Related

Password edittext hint text alignment on right side [duplicate]

This question already has answers here:
Android RTL password fields?
(6 answers)
Closed 6 years ago.
I'm facing an issue that when I define an EditText as password type and view my screen in Arabic language the password field hint text is showing on the left side instead of right side [that is expected].
Above is the result I get. I need password hint text to be starting from the right side that's where Arabic writings start. I've also tried adding text gravity to it but no luck.
Please refer to this post :
Android RTL password fields?
For API 17+ you can use
android:textAlignment="viewStart"
Try this:
<EditText
android:id="#+id/input_password"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="كلمة المرور"
android:textColorHint="#FFFFFF"
android:gravity="right"
android:inputType="textPassword"
android:background="#null"
android:textColor="#FFFFFF"
android:textSize="20dp"/>

TextInputEditText not showing drawableRight icon [duplicate]

This question already has answers here:
Unable to use drawable in EditText inside TextInputLayout
(5 answers)
Closed 6 years ago.
I am using code bellow to display User name Input. EditText is working properly but Right side display icon is not visible.
<android.support.design.widget.TextInputLayout
android:id="#+id/login_screen_edit_text_username_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="#+id/login_screen_edit_text_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/label_username"
android:inputType="text"
android:drawableRight="#mipmap/email_icon"
android:text="abcd#gmail.com"
/>
</android.support.design.widget.TextInputLayout>
I am testing this code on Nexus6p android version 6.0. Parent layout is LinearLayout.Please update if anybody facing same issue and got fix for it.
use
android:drawableEnd="#mipmap/email_icon"
instead of
android:drawableRight="#mipmap/email_icon"

Android EditText not Multi Line [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
restrict edittext to single line
I have 2 edit texts. My problem is, when I press the enter button in the keyboard, it creates another set of line. Or it creates like a next line in my edit text. I want to remove it and I want it to be in single line. Even if I enter the enter key in the keyboard, still it won't create a next line.
How do you do it?
Try this in your EditText xml
android:singleLine="true"
<EditText
android:id="#+id/edittextView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:singleLine="true"/>
Try this with your edit text in layout

How to replace text in a textfield when user enters any character [duplicate]

This question already has answers here:
TextView to display hint before text entered
(2 answers)
Closed 8 years ago.
In my android app I have a text field that says "how much would you like to take".
I want the text to be erased automatically and replaced by what the user inputs when they type in that textfield.
Example: if the user enters one character it automatically deletes "how much would you like to take" from the text field and replaces it with the one character that's been entered.
In your xml file use
android:hint="how much would you like to take"
in your TextView definition
(Well, it should be something like "#string/how_much" and that how_much string in strings.xml, but honestly...)
Its called android:hint property of a EditText you can set it into your xml file.
Something like that.
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="how much would you like to take" />
Try this in your xml
Use this in below code android:hint="how much would you like to take"
<EditText
android:id="#+id/edtName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/txtName"
android:layout_marginRight="5dip"
android:hint="how much would you like to take"
android:inputType="textCapSentences"
/>
Hope it helps

What does the ? in Android XML mean [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Question mark (?) in XML attributes for Android
<TextView android:id="#+android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:ellipsize="marquee"
android:fadingEdge="horizontal" />
what does "?android:attr/textAppearanceLarge" do? Does it have a name? Why doesn't it use an "#" instead? Can I use this syntax in my own code? Where can I read more about this? Since I don't know what it is, it's kind of hard to find more information about it. Any guidance would be greatly appreciated.
This question has already been asked on stackoverflow.
The answer given was:
The question mark means it's a reference to a resource value in the
currently applied theme.
Look here for more details.
It is a reference to style attribute. Check this reference:
References To Theme Attributes

Categories

Resources