android-edittext

TextInputLayout: RuntimeException - Failed to resolve attribute at index 24

若如初见. 提交于 2019-11-30 17:05:29
I keep on getting this error when I try to setErrorEnabled on my textInputLayout : 03-12 12:29:03.206 5706-5706/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.myapp, PID: 5706 java.lang.RuntimeException: Failed to resolve attribute at index 24 at android.content.res.TypedArray.getColor(TypedArray.java:401) at android.widget.TextView.<init>(TextView.java:696) at android.widget.TextView.<init>(TextView.java:632) at android.widget.TextView.<init>(TextView.java:628) at android.widget.TextView.<init>(TextView.java:624) at android.support.design.widget.TextInputLayout.setErrorEnabled

How to add margin between EditText and Soft Keyboard?

你说的曾经没有我的故事 提交于 2019-11-30 17:00:08
I want to add 10dp margin between EditText and Soft Keyboard. Here is my XML: <RelativeLayout android:id="@+id/BottomLayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:background="@drawable/bottom_glass" > <EditText android:id="@+id/message" android:layout_width="200dp" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:background="@drawable/grey" android:ems="10" android:layout_marginBottom="10dp" android:hint=

Why we use String message = editText.getText().toString() after using EditText editText = (EditText) findViewById(R.id.edit_message); [closed]

本小妞迷上赌 提交于 2019-11-30 16:46:07
I am new to android development. I am learning android development given here their is a piece of code Intent intent = new Intent(this, DisplayMessageActivity.class); EditText editText = (EditText) findViewById(R.id.edit_message); String message = editText.getText().toString(); intent.putExtra(EXTRA_MESSAGE, message); I want to know why we use String message = editText.getText().toString() after using EditText editText = (EditText) findViewById(R.id.edit_message); What does EditText return? Using EditText editText = (EditText) findViewById(R.id.edit_message); This line registers your xml

Create a multiline EditText programmatically

浪子不回头ぞ 提交于 2019-11-30 16:30:54
问题 I am trying to create a multiline EditText by code. This is what I use: EditText txt = new EditText(this); lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1.0f); txt.setLayoutParams(lp); txt.setSingleLine(false); txt.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE); But it is still in one single line. 回答1: This should do it txt.setSingleLine(false); txt.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION); 回答2: You may also use this: txt.setInputType

EditText maxLength property not applied properly when setFilters is used

做~自己de王妃 提交于 2019-11-30 15:45:57
问题 When I use setFilter method on an EditText to handle special characters, maxLength property is not working as expected. My code is below. editName = (EditText)findViewById(R.id.rna_editTextName); editName.setFilters(new InputFilter[]{getFilteredChars()}); //Below method returns filtered characters. public InputFilter getFilteredChars() { InputFilter filter = new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {

EditText maxLength property not applied properly when setFilters is used

帅比萌擦擦* 提交于 2019-11-30 15:17:23
When I use setFilter method on an EditText to handle special characters, maxLength property is not working as expected. My code is below. editName = (EditText)findViewById(R.id.rna_editTextName); editName.setFilters(new InputFilter[]{getFilteredChars()}); //Below method returns filtered characters. public InputFilter getFilteredChars() { InputFilter filter = new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { if (end > start) { char[] acceptedChars = new char[]{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',

CoordinatorLayout messing up setError popup position

荒凉一梦 提交于 2019-11-30 15:08:29
问题 I'm facing an issue with EditText setError popup position. I'm using the following code in to create the layout: activity_profile.xml <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools

Different colors at EditText in Android

女生的网名这么多〃 提交于 2019-11-30 14:59:49
I am trying to make the text of an EditText multiple colors. For example, if my text is, "It is a good day.", is it possible to make the "It is a" part of the sentence green and the rest red? I use something like that to make some parts of my color green: final String text = "Some Text"; Spannable modifiedText = new SpannableString(text); modifiedText.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.green)), 0, lengthYouWant, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(modifiedText); You could use spannables . Spannable spannable = yourText.getText(); spannable

editText is not losing focus

﹥>﹥吖頭↗ 提交于 2019-11-30 14:36:01
问题 the editText is not losing focus in my app when I click out of it, it has the orange border all time and that black line cursor.. I did this a LinearLayout according to this surrounding the editText: Stop EditText from gaining focus at Activity startup so it doesn't get focus on start of the app.. this is my code: final EditText et = (EditText)findViewById(R.id.EditText01); final InputMethodManager imm = (InputMethodManager) getSystemService( INPUT_METHOD_SERVICE); et.setOnClickListener(new

Android - Soft Keyboard pushes layout of my activity out of screen

爱⌒轻易说出口 提交于 2019-11-30 14:32:40
问题 My activity's layout is as shown below. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <FrameLayout android:id="@+id/title_bar" android:layout_width="fill_parent" android:layout_height="25dip" android:background="@drawable/bg_title" /> <LinearLayout android:id="@+id/main" android:width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1">