Tag: android edittext

将光标置于EditText中的文本末尾

我正在改变keyListener上的EditText的值。 但是当我改变文本时,光标正在移动到EditText的开头。 我需要将光标放在文本的末尾。 如何将光标移动到EditText文本的末尾。

EditText错误图标和显示密码错位

我有一个EditText作为密码input像这样 <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:id="@+id/password" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/prompt_password" android:imeActionId="@+id/login" android:imeActionLabel="@string/action_sign_in_short" android:imeOptions="actionUnspecified" android:inputType="textPassword" android:maxLines="1" android:singleLine="true" /> </android.support.design.widget.TextInputLayout> 它的工作,但是当出现错误错误图标shwon两次,它是显示密码图标的顶部。 我的validation码显示错误: if (success) { finish(); startMainActivity(); } else { mPasswordView.setError(getString(R.string.error_incorrect_password)); mPasswordView.requestFocus(); }

在edittext中绘制多行,例如记事本

我正在看Android SDK中的记事本示例,请看这里: http : //developer.android.com/resources/samples/NotePad/src/com/example/android/notepad/NoteEditor.html 事情是只绘制光标所在的当前行,例如http://cdn2.staztic.com/screenshots/simple-notepad-app-al-1.jpg 但是我想要显示填满屏幕的行,例如http://www.itismyworld.info/wp-content/uploads/2010/03/AK-notebook.png 任何build议将是伟大的。 代码的相关部分似乎在这里: protected void onDraw(Canvas canvas) { // Gets the number of lines of text in the View. int count = getLineCount(); // Gets the global Rect and Paint objects Rect r = mRect; Paint paint = mPaint; /* * Draws one line in the rectangle for every […]

Android:EditText失去滚动ListView中的内容?

我有EditText列表项目,我不知道会有多less项目。 当我在EditTextinput一些文本时出现问题,然后向下滚动ListView ,再次向上滚动后,我的第一个EditText没有文本,或者ListView其他EditText有一些文本。 我已经尝试了TextWatcher ,并将数据保存到数组,但问题是在ListView中返回的视图位置并不总是正确的,所以我从数组中丢失了一些数据。 请帮忙。 这是我的代码: public class EfficientAdapter extends BaseAdapter { private LayoutInflater mInflater; public String[] Current; ArrayList<String> MeterName, PreviousReading, Current_Reading; JSONArray getArray_Meter_Reading; public EfficientAdapter(Context context, JSONArray getArray_Meter_Reading) { mInflater = LayoutInflater.from(context); this.getArray_Meter_Reading = getArray_Meter_Reading; MeterName = new ArrayList<String>(); PreviousReading = new ArrayList<String>(); for (int i = 0; i < getArray_Meter_Reading.length(); i++) { […]

如何在EditText中设置文本

我如何设置EditText的文本?

获取焦点时,selectEditText中的所有文本

我有一个与其中的一些虚拟文本的EditText。 当用户点击它,我希望它被选中,以便当用户开始input时,虚拟文本被删除。 我怎样才能做到这一点?

将edittext限制为单行

可能的重复: android-singleline-true-not-working-for-edittext <EditText android:id="@+id/searchbox" android:layout_width="fill_parent" android:layout_height="wrap_content" android:lines="1" android:scrollHorizontally="true" android:ellipsize="end" android:layout_weight="1" android:layout_marginTop="2dp" android:drawablePadding="10dp" android:background="@drawable/edittext" android:drawableLeft="@drawable/folder_full" android:drawableRight="@drawable/search" android:paddingLeft="15dp" android:hint="search…"> </EditText> 我想让上面的EditText只有一行。 即使用户按下“enter”键,光标也不会下到第二行。 有人能帮我做吗?

如何检查edittext的文本是否是电子邮件地址?

如何检查edittext的文本是电子邮件地址或不使用javascript和正则expression式? 在这里,我使用inputtype="textEmailAddress"这是工作,但没有错误消息显示。

EditText setError()带有图标但没有popup消息

我想对我的EditText进行一些validation,在那里我想显示“ “图标(当你把editText.setError("blah blah"))但不希望popup文本显示”等等等等“。 有没有办法做到这一点? 一种方法是创build一个自定义布局,在EditText中显示图像图标。 但有没有更好的解决scheme?

如何在代码中复制android:editable =“false”?

在布局中,您可以通过android:editable attribute将EditText小部件设置为不可编辑的。 我如何在代码中做到这一点? 我需要使EditText小部件可以根据条件进行编辑。