android-edittext

Save entered text in editText via button

送分小仙女□ 提交于 2019-11-30 07:42:55
问题 i want to save a String 's value that is entenred in EditText using sharedPreferences. and show text when activity starts public class enteredText extends Activity { private Button savenotebutton1; private SharedPreferences savednotes; private EditText editText1; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.x1); savenotebutton1 = (Button) findViewById(R.id.savenotebutton1); editText1 = (EditText) findViewById(R.id

How to retrieve multi-line text from Edittext?

不想你离开。 提交于 2019-11-30 07:41:17
问题 I want to get a text(Multi-line) from Edittext same as given Screenshot. I want below output when getText() from Edittext. Output: Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text. I have tried below solution but, it doesn't work etMessage.getText().toString().replaceAll("\\n", "<br />") 回答1: After too much searching and waiting for an answer to this question. I have resolved this issue. Solution: I have measured

Drop shadow around all the four sides of an EditText in Android Studio

百般思念 提交于 2019-11-30 07:40:58
问题 As far as my knowledge aids me, there isn't any property to drop shadow around an EditText field, that can be set in the layout file. I searched for the problem and found solution that I've to provide a custom background xml drawable. My drawable/background_with_shadow looks like this: <?xml version="1.0" encoding="utf-8"?> <layer-lis xmlns:android="http://schemas.android.com/apk/res/android"> <item > <shape android:shape="rectangle"> <solid android:color="@android:color/darker_gray" />

Android Listview with spinner and a checkbox

[亡魂溺海] 提交于 2019-11-30 07:37:41
问题 I am a newbie to android development. I am trying to create a List which has a spinner, a edit text and a check box. The data for spinner and check box come from data base. I have the following files. NewTransac class which extends ListActivity { private PayDbAdapter mDbHelper; private Spinner paySpinner; private CheckBox mCheckBox; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.new_transac_listview); mDbHelper = new

Android EditText Memory Leak

拜拜、爱过 提交于 2019-11-30 07:31:33
Alot of people are noticing EditText in an activity is holding a Strong Reference to an Activity even once its finished. To be clear this EditText is inside a layout and inflated, there is no Listeners set. This only happens on certain devices e.g. Samsung Galaxy S4 (Android 4.2.2) and others. Many post about this still no solution. First here is some useful posts. (Eventually GC will clean this so its not technically a leak, but for heavy memory apps it takes way to long and will cause OOM) Android Samsung Memory leak in EditText Why does EditText retain its Activity's Context in Ice Cream

onCreateContextMenu() for EditText doesn't work on real device

本小妞迷上赌 提交于 2019-11-30 07:24:34
Just tried to test my app on real device (HTC Desire Z with Android 2.2). And found that my context menus doesn't work at all on EditText s. Otherwise context menus works: in ListView , ImageView and so on. On emulator everything works fine... When I tap on EditText it shows something like zoom frame and then shows unusual (not standard Android alike) context menu which reads: "select text", "select all". It doesn't show my menus. Here are screenshots: Before tap During tap After tap (just ordinary select text, select all, paste) but no my menu like in emulator - look here Here's source code

Why does the input value in EditText swaps its position while scrolling in a RecyclerView?

穿精又带淫゛_ 提交于 2019-11-30 07:24:06
After putting an input in the EditText, if a scroll up or down very fast the input values swaps its position in another EditText in a RecyclerView. Before scrolling the data was in the first EditText. After scrolling up and down the value of the first EditText changed its postion to the 4th one and the swapping is random. Is there any work around to steady the data. Here is a sample screenshot Here is the Model Class: public class Product { public int pId; public String pName; public double unit_price; public double discount; } Here is the adapter Class: public class ProductAdapter extends

Android EditText Memory Leak

南笙酒味 提交于 2019-11-30 07:02:57
问题 Alot of people are noticing EditText in an activity is holding a Strong Reference to an Activity even once its finished. To be clear this EditText is inside a layout and inflated, there is no Listeners set. This only happens on certain devices e.g. Samsung Galaxy S4 (Android 4.2.2) and others. Many post about this still no solution. First here is some useful posts. (Eventually GC will clean this so its not technically a leak, but for heavy memory apps it takes way to long and will cause OOM)

How to force EditText to accept only numbers?

坚强是说给别人听的谎言 提交于 2019-11-30 06:33:52
问题 how to force the EditText to accept only numbers.? 回答1: Use android:inputType="number" in your layout XML 回答2: This also works fine: android:digits="0123456789" 回答3: Or you can add the following: yourEditText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED); this will accept numbers, float point numbers and negative numbers you can remove any of these as needed 回答4: You can use android:inputType="number" in the XML file. You

Set cursor position in android Edit text [duplicate]

不羁的心 提交于 2019-11-30 06:11:22
This question already has an answer here: Android EditText how to start cursor pointer at the end of all characters- not end of first line 2 answers How can i set the cursor position in android edit text? I have an edit text and on create i want to set the cursor to some times in the end some times in the middle of the text, what can i do? my edit text is as follows: android:id="@+id/editText11" android:layout_width="wrap_content" android:layout_height="200sp" android:layout_above="@+id/horizontalScrollView1" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android