android-edittext

How to bold or italic or underline the selected text in Edittext programatically

别等时光非礼了梦想. 提交于 2019-12-12 09:26:08
问题 I have to develop an App like sticky note. User enter the text in Edittext, while selecting the text I will open the popup to select the option like (BOLD,ITALIC,UNDERLINE). when user select the options i need to change the selected text.. Does anyone go through this? 回答1: If you have found a way the popup the options and how to retrieve the selected option(Bold, Italics, Underline), Then use this to format the text private void formatText(EditText editText) { int end = editText.length(); /

How to hide keyboard on enter key

懵懂的女人 提交于 2019-12-12 08:37:33
问题 i have an activity with four edittext and i want to hide keyboard when users finish to use one of the four edittext. if i click enter on keyboard, it will focus another edittext and keyboard still remain, but i need to hide keyboard, so to use only one edittext and not necessarily the other. This is xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android

Android EditText: How to create an empty bullet paragraph by BulletSpan?

↘锁芯ラ 提交于 2019-12-12 08:35:22
问题 I use the same title with this question, because I think my question is very similar to that one, I read and tested the accepted answer very carefully, however the accepted answer doesn't work for me. Let me describe my question: My code looks like: EditText myEdit = (EditText) this.findViewById(R.id.myedit); myEdit.setText("a\nb\n"); Spannable s = myEdit.getText(); s.setSpan(new BulletSpan(30), 0, 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); s.setSpan(new BulletSpan(30), 2, 3, Spannable.SPAN

Android Handling many EditText fields in a ListView

懵懂的女人 提交于 2019-12-12 08:02:10
问题 Just a basic question: If I have several dozen EditText fields that are part of a ListAdapter, how can the individual EditText fields know to which row they belong? Currently I am using TextWatcher to listen for text input. I have tried extending TextWatcher so that I can pass in the position of the EditText to TextWatcher's constructor. However, when the soft keyboard pops up, the positions that correspond to the various EditText fields shuffle. How can I track the EditText fields to their

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

懵懂的女人 提交于 2019-12-12 07:09:49
问题 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"

Set EditText to be Multiline(Enter is carrige return) and not display suggestions

[亡魂溺海] 提交于 2019-12-12 06:52:39
问题 I am trying to set a Android EditText to be Multiline, and not display any suggestions. textView.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE); However, this is just a single line. Currently pressing the enter/carriage return button hides the keyboard, instead of moving to a new line. textView.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION); Setting the IME flag causes the enter button to insert whitespace. I need to display no suggestions

EditText decimal value

一笑奈何 提交于 2019-12-12 06:49:29
问题 I'm implementing EditText 's and I'm facing with one issue... I've put that the inputType is numberDecimal but at the time I type on the EditText I'd like to put the "." or "," autommatically... I can put for example 100.00 or 90.00 it depends of the user... Can it be possible? I tried to create a TextWatcher and do some things on onTextChanged like see if the charSequence-lenght()==2 add a "." or "," but doesn't work... Can I detect when to put the comma or dot even if I have a decimal

How to change EditText background color when I enter text?

孤街浪徒 提交于 2019-12-12 06:39:02
问题 My EditText has some color, but when I enter some text it should change. Say it's grey, I started to enter and it's yellow. This EditText is also focused, so when this activity starts -- I already can enter the text. How I tried: <style name="LoginEnterField"> <item name="android:textColorHint">@color/black</item> <item name="android:textColor">@color/black</item> <item name="android:background">@drawable/selector_edittext</item> <item name="android:textSize">@dimen/general_text_size</item>

numberFormatException

烈酒焚心 提交于 2019-12-12 06:22:35
问题 Is this sequence correct in android? I am tring to get EditText value and convert it into integer. startTime_hour_int=Integer.parseInt(startTime_hour_edittext.getEditableText().toString()); Because my logcat throws the below error. 05-12 10:26:35.536: ERROR/AndroidRuntime(293): java.lang.NumberFormatException: unable to parse '' as integer Can anyone tell me, how to solve this? 回答1: @Andro_Selva If textbox startTime_hour_edittext is blank then Integer.parseInt is trying to parse "" into

How to use getSelectionStart and getSelectionEnd of EditText when user touches EditText?

被刻印的时光 ゝ 提交于 2019-12-12 06:17:49
问题 I want to know by using which method I can get whether the user selecting text in edittext or not so I can use getSelectionStart and getSelectionEnd to perform my desire task. 回答1: You can check if your EditText widget has been focused (usually when user touches it on the screen). findViewById(R.id.editText1).setOnFocusChangeListener(this); and then implement the listener (in this case within the same class) public void onFocusChange(View arg0, boolean arg1) { switch(arg0.getId()){ case R.id