android-edittext

Why EditText in a custom compound view is re-using the text entered in another compound view instance?

若如初见. 提交于 2019-11-30 02:23:26
I'm trying to write a custom compound view composed by a TextView and an EditText , _compound_view.xml_: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/compoundText" android:layout_width="match_parent" android:layout_height="wrap_content" > <TextView android:id="@+id/textLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Label" /> <EditText android:id="@+id/textEdit" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="enter text here" > </EditText> and this is the class

Edit text Password Toggle Android

那年仲夏 提交于 2019-11-30 02:06:01
I am trying to show user the typed password in edit text whose input type is text Password. I implemented gesturelistener over the toggle icon like this- public boolean onTouch(View view, MotionEvent motionEvent) { switch (view.getId()) { case R.id.ivPasswordToggle: switch ( motionEvent.getAction() ) { case MotionEvent.ACTION_DOWN: Toast.makeText(getContext(),"show",Toast.LENGTH_SHORT).show(); etPassword.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); break; case MotionEvent.ACTION_UP: etPassword.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_CLASS_TEXT);

Extending a EditText in Android. What am I doing wrong?

人走茶凉 提交于 2019-11-30 02:05:40
问题 So I'm trying to get a grasp of using custom controls in Android. But my app crashes on trying to create the activity. Here's the code: package com.myApp; import android.content.Context; import android.widget.EditText; import android.view.View; import android.view.View.OnClickListener; public class MyEditText extends EditText implements OnClickListener { public MyEditText(Context context) { super(context); // TODO Auto-generated constructor stub } public void FlashBorder() { //do some custom

Change background color of edittext in android

谁说胖子不能爱 提交于 2019-11-30 01:34:25
If I change the background color of my EditText using the below code, it looks like the box is shrunken and it doesn't maintain the ICS theme of a blue bottom border that exists for a default EditText . <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#99000000" > <EditText android:id="@+id/id_nick_name" android:layout_marginTop="80dip" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#ffffff" />

How to get text from EditText?

只谈情不闲聊 提交于 2019-11-30 01:04:10
问题 The question is quite simple. But I want to know where exactly do we make our references to the gui elements? As in which is the best place to define: final EditText edit = (EditText) findViewById(R.id.text_xyz); edit.getText.tostring(); When I try it doing inside the default oncreate() I get null values. So for best practice, do u recommend a separate class for referring these already defined gui elements in main.xml. From here we can call various methods of these elements like gettext or

Validate an email inside an EditText [duplicate]

倖福魔咒の 提交于 2019-11-30 00:24:46
This question already has an answer here: How to check edittext's text is email address or not? 16 answers I want to validate an email introduced inside an EditText and this the code that I already have: final EditText textMessage = (EditText)findViewById(R.id.textMessage); final TextView text = (TextView)findViewById(R.id.text); textMessage.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { if (textMessage.getText().toString().matches("[a-zA-Z0-9._-]+@[a-z]+.[a-z]+") && s.length() > 0) { text.setText("valid email"); } else { text.setText("invalid email"); }

TextInputLayout: RuntimeException - Failed to resolve attribute at index 24

你说的曾经没有我的故事 提交于 2019-11-30 00:23:59
问题 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

Setting text in EditText Kotlin

℡╲_俬逩灬. 提交于 2019-11-30 00:12:21
I am trying to set text in a EditText but it says: Type mismatch. Required: Editable Found: String My code is as follow: String name = "Paramjeet" val nametxt = findViewById (R.id.nametxt) as EditText nametxt.text = name Don't say to use setText because I am using kotlin, not Java. Use setText(String) , since editText.text expects an Editable , not a String . Use setText(String) as EditText.text requires an editable at firstplace not String WHY ? Nice explanation by Michael given under this link . Do visit this link for more detail When generating a synthetic property for a Java getter/setter

How to avoid multiple triggers on EditText while user is typing?

女生的网名这么多〃 提交于 2019-11-30 00:11:06
I use the following code to perform search when user types in an EditText : EditText queryView = (EditText) findViewById(R.id.querybox); queryView.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { triggerSearch(s.toString()); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); However, this triggers multiple times when the user is typing a word. That is if the user is typing "hello", this code will trigger 5 times

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

回眸只為那壹抹淺笑 提交于 2019-11-30 00:03:29
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . 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