android-edittext

How to make android EditText smaller than default in height?

佐手、 提交于 2019-11-29 03:17:40
How to make android EditText smaller than default in height? If I change the height, I can't see my text, but it has extra blank on bottom. bhatt4982 EditText has a default padding set. Try this, <EditText android:text="Any Text" android:layout_width="fill_parent" android:layout_height="16dp" android:padding="2dp" android:background="#FFF" android:textSize="10dp" /> learn_andrd Use android:textAppearance="?android:attr/textAppearanceSmallInverse" For further reference, see this : http://developer.android.com/guide/topics/ui/themes.html I wasn't really satisfied with any of the answers there

How can I get the results from an AlertDialog?

我的未来我决定 提交于 2019-11-29 03:02:22
I am using an AlertDialog.Builder to display a dialog to prompt the user to enter a password, I then want to save that password in a preference, however I can't figure out how to get the result from the alert dialog's input method. Here is essentially what I would like to be able to do: String result; AlertDialog.Builder b = new AlertDialog.Builder(this); b.setTitle("Please enter a password"); final EditText input = new EditText(this); b.setView(input); b.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { //I

EditText background base line color changing based on its focus in android

只愿长相守 提交于 2019-11-29 03:00:28
I need to design EditText with base line showed in below image and it will be change to some other color when it receives focus.! i am using the following. <EditText android:id="@+id/mobilenumber" android:drawableLeft="@drawable/mobile" android:drawablePadding="15dp" android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="number" android:background="@drawable/edt_bg" android:singleLine="true" android:textColorHint="#FFFFFF" android:hint="@string/mobilenumber" android:layout_marginTop="20dp" android:layout_gravity="center" android:padding="5dp" android

make editText lose focus on back press

早过忘川 提交于 2019-11-29 02:59:35
In my activity, I have a editText field. When the user taps on it, the editText gains the focus and the keyboard appears. Now, when the user presses the hardware back button on the phone, the keyboard disappears but the cursor remains in the Edittext, i. e., it still has the focus. Is it possible to make the EditText lose focus when back button is pressed? I tried using the following code but it didn't work: @Override public void onBackPressed() { vibrator.vibrate(Constants.DEFAULT_VIBRATE_TIME); myEditText.clearFocus(); super.onBackPressed(); } Just extend EditText: public class EditTextV2

Difference between android:inputType=“textPassword”, “textVisiblePassword”,“textWebPassword” and “numberPassword” in android?

╄→гoц情女王★ 提交于 2019-11-29 02:58:12
Can anyone explain the differences between the android:inputType="textPassword", android:inputType="textVisiblePassword", android:inputType="textWebPassword", android:inputType="numberPassword" of EditText ViewGroup in Android Layout? S.Thiongane From the doc for android:inputType : textPassword Value: 0x00000081 Text that is a password. Corresponds to TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD . textVisiblePassword Value: 0x00000091 Text that is a password that should be visible. Corresponds to TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_VISIBLE_PASSWORD . textWebPassword Value: 0x000000e1 Text

Where should I put the “ttf” files in an Android project?

穿精又带淫゛_ 提交于 2019-11-29 02:56:34
I'm trying to use fonts in my project using Typeface. I copied the "font.ttf" into a folder named "fonts" inside "assets" folder. But eclipse do not allow to compile it. It shows an error on fonts folder. What should I do? The error I get is: invalid resource directory name fonts /NoRats/assets line 1 Android AAPT Problem Nikhil Please check this link , it may be helpful to you. OR use below code. Typeface tf = Typeface.createFromAsset(this.getAssets(),"fonts/LATINWD.TTF"); txt1.setTypeface(tf); .ttf file is in --> assets/fonts/LATINWD.TTF Please first clean your project then check again.

Cannot Type EditText in ExpandableListView Child

天涯浪子 提交于 2019-11-29 02:45:05
i am using expandableList and each child has its edittext to enter a number... when the child is pressed, the edittext shows. if it is not, the edittext stays invisible.. but when i tap on the edittext, the keyboard shows in number (because i set type input : number) only 1 second. after that it turns to common keyboard. even it backs to common keyboard, still, i cant type on the edittext... here is my code public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { // TODO Auto-generated method stub final String childText = (String

EditText in GridView : How to get value from Multiple EditText

二次信任 提交于 2019-11-29 02:37:20
I have created GridView using following XML code: grid_layout.xml <GridView android:id="@+id/productList" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="5dp" android:layout_marginBottom="10dp" android:drawSelectorOnTop="true" android:fastScrollEnabled="true" android:horizontalSpacing="10dp" android:listSelector="@drawable/list_view_selector" android:numColumns="3" android:stretchMode="columnWidth" android:verticalSpacing="10dp" > </GridView> <!-- android:listSelector="@drawable/list_view_selector" is not affecting --> and I have bind that GridView

Android how to make EditText editable inside a ListView

与世无争的帅哥 提交于 2019-11-29 02:24:49
I have a ListView with edit text in each items and I want to know how can I make the EditText editable.. It seems to work fine if I set the android:windowSoftInputMode="adjustPan" into the manifest but only on some devices. On some devices the soft keyboard covers the edittext. On the other side, if I don't put android:windowSoftInputMode="adjustPan" in the manifest, the EditText looses focus after the soft keyboard is displayed and I have to touch the EditText multiple times to make it selected and can write in it. Please help me solve this. Note: I've seen this post: Focusable EditText

How to implement Multiline EditText with ActionDone button (without Enter button)

我们两清 提交于 2019-11-29 02:21:11
问题 I have EditText which is used for entering contents on messages (emails, sms). I want message to be immediately posted on ActionDone button click. I use following code for this: message.setOnEditorActionListener((textView, i, keyEvent) -> { switch (i) { case EditorInfo.IME_ACTION_DONE: if (messageCanBePosted()) { SoftKeyboard.hide(message); postMessage(); return true; } else { return false; } default: return false; } }); But also I want this message field to be multiline, like in any other