android-edittext

How to dynamically add edittext to android

纵然是瞬间 提交于 2019-12-03 22:38:30
问题 I want to add edittext dynamically to the android display. I want to make something like in the android contacts where you can dynamically add fields and remove them if you dont need them. Thank you for your help 回答1: See Everything dynamically TextView tv=new TextView(this); tv.setText("TaskID"); TextView tv1=new TextView(this); task=new EditText(this); task.setMaxWidth(100); task.setMinHeight(100); tv1.setText("Task"); id=new EditText(this); id.setMaxHeight(10); TextView tv2=new TextView

How to make edit text error position in android?

谁说我不能喝 提交于 2019-12-03 22:25:15
问题 I have an app in which I have edit text fields in which I have to enter a mobile number and password. The problem is that the EditText error indicator covers the mobile number and password filed, and the user will not be able to enter mobile number. How do I solve this? 回答1: Use this android.support.design.widget.TextInputLayout . which can show the error below to the Edittext .so You can easily write next thing like your number and password in the new Edittext . Here is xml code :

EditText vs TextView

孤街浪徒 提交于 2019-12-03 22:13:25
I read the API's and see that TextView is a super class to EditText , but I have a short and simple question: Generally speaking, EditText is used when the text displayed is subject to change, whether it's from the user or the app. TextView is used when the text displayed is to be constant/same forever. Is this correct? If you have done any java projects before, I see Textview and EditText are just same as JLabel and JtextField . If you want to ask user to enter username you will set an TextView with ("username " text in that, like you would do the same for JLabel). And then you make a textbox

Edittext underline color when contain text (“>Lollipop”)

时光怂恿深爱的人放手 提交于 2019-12-03 21:50:46
I want to change the underline color of my editText when they have text inside them otherwise make a default color. whatever the state, I want to do the following Edittext: When they have text -> Underline color (Blue) Edittext: when they empty -> underline color (Gray) It works on Lollipop and below, but it's not working on Android versions above Lollipop. I did the following: XML <android.support.design.widget.TextInputLayout android:id="@+id/input_password_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="26dp" android:gravity="center

Android: why i am not able to change the value of EditText with respect to another EditText?

ぐ巨炮叔叔 提交于 2019-12-03 21:29:26
问题 I am going to change the text of the edittext based on the value enter on the another edittext. and also like same thig with visa-versa. For that i have use the TextChanged Listener and implemented as like below: includedText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if(!(includedText.getText().toString().equals(""))) { double included = Double.parseDouble(includedText.getText().toString()); included =

is it possible multiline with input type as number in Android Edittext?

六月ゝ 毕业季﹏ 提交于 2019-12-03 20:54:24
问题 When the android edittext input type is number, is it possible to make multilines? I have tried with the following in xml file. android:inputType="number|textMultiLine" But it did not work. Is it not possible to make multiline when the input type is number? Please help me in this. Thank you. 回答1: Please do this: android:inputType="textMultiLine|number" android:digits="0,1,2,3,4,5,6,7,8,9" Taken from here: Answer 回答2: I tried each and every solution for your problem.The thing is that when you

Positioning EditText Above Keyboard

倖福魔咒の 提交于 2019-12-03 20:39:12
问题 I have got an EditText looking like this (with "bottom gravity"): When I press the EditText , the keyboard shows up and I can't see anymore what I'm typing (because the EditText is now behind the keyboard, on the bottom). How could I move the EditText automatically just above the keyboard, when it has been pressed? At the end, it would be good if it would look like this: My Code: // LINEAR LAYOUT LinearLayout layout = new LinearLayout(getApplicationContext()); layout.setOrientation

Different colors at EditText in Android

巧了我就是萌 提交于 2019-12-03 20:12:27
问题 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? 回答1: 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

How to detect special characters in an edit text and display a Toast in response (Android)?

江枫思渺然 提交于 2019-12-03 19:34:48
问题 An apology for my bad English, I'm using google translate. I'm creating an activity in which users must create a new profile. I put a limit to edit text of 15 characters and I want that if the new profile name has spaces or special characters display a warning. As online video games The following code helps me to detect spaces, but not special characters. I need help to identify special characters and display a warning in response. @Override public void onClick(View v) { //Convertimos el

android, how to draw dotted line in edittext

廉价感情. 提交于 2019-12-03 18:14:12
问题 I refered to this link: How do I make a dotted/dashed line in Android?, and used DashPathEffect . But this does not work for me? why? my code: public class NoteEditText extends EditText { private Paint mPaint; public NoteEditText(Context context) { super(context); } public NoteEditText(Context context, AttributeSet attrs) { super(context, attrs); mPaint = new Paint(); mPaint.setStrokeWidth(1); mPaint.setStyle(Paint.Style.FILL_AND_STROKE); mPaint.setColor(Color.DKGRAY); PathEffect effects =