android-edittext

Simple Edittext Math Android

淺唱寂寞╮ 提交于 2020-01-07 08:29:29
问题 new SO user here and I'm new to android as well. I need help doing a simple calculation between two edittext boxes - without a button, using a textwatcher, so that after the user is done using the edittext boxes it can add the two together and output the answer in a textview. I'd post my code here, but it just isn't any good. Can anyone provide an example of how to take two edittext boxes, assign a textwatcher to both, then put the output into a textview. Also, please keep in mind that this

How to default an EditText to integer but allow decimal input?

江枫思渺然 提交于 2020-01-07 05:37:13
问题 I am using an EditText to allow a user to input a value that is stored in a Double. However, by default, Doubles look like "0.0" and it's a little annoying for a user to backspace over the extra decimal if it's not used. Is there a way to force-display whole numbers to look like "0" and only show the decimal if the user actually decides to use it? Current code: myEditText = (EditText) view.findViewById(R.id.my_edittext); myEditText.setText(myVariable + ""); myEditText.addTextChangedListener

Unable to get line number on press of ENTER

 ̄綄美尐妖づ 提交于 2020-01-07 05:00:51
问题 I have an edittext, on press of ENTER key i want to call a function and go to next line, and i want to have the line number of my current line after pressing enter. I am using edittext.onKeyListner scene.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { // TODO Auto-generated method stub if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { // Perform action on key press String s = scene.getText()

Android how to create edit text with single line input and multiline hint

▼魔方 西西 提交于 2020-01-07 03:24:07
问题 I am looking to create an edit text with a 3-4 line hint which on click, allows the user to enter only a single line of text. I have tried to use android:singleLine = "true" But that limits the length of the hint as well. How do I assign different number of lines for both ? Thanks 回答1: You could add a TextWatcher to your edit text and compare the length of the text. If it is 0, then the hint is shown and you programmatically set editText.setSingleLine(false). If it is greater than 0, you

How to hide default Android keyboard when custom keyboard is visible?

杀马特。学长 韩版系。学妹 提交于 2020-01-07 03:03:29
问题 I have an Android app with Activity containing a TextView as below. <EditText android:id="@+id/textEdit1" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingLeft="8dip" android:paddingRight="8dip" android:lines="4" android:hint="My hint" android:layout_gravity="center_horizontal|center_vertical" android:gravity="left" android:selectAllOnFocus="true" android:textAppearance="?android:attr/textAppearanceSmall"/> When the user clicks within this TextView (and

How do I add an “edittext” that when you type in a specific word an action happens

落爺英雄遲暮 提交于 2020-01-07 02:44:10
问题 How do I add a "edittext" that when you type in a specific word such as "apple" it will make a new xml page pop up. But if the user types in a different word besides "apple" it will make a different xml page pop up. What I'm trying to accomplish is somethings similar to a logo quiz game where when you type in the right word, a new thing pops up. I have absolutely no idea how to do it. if u could show me a video on how to do it, that would be very helpful thanks! :) 回答1: You should use a

How to get a result data to edit text without clicking on button?

房东的猫 提交于 2020-01-06 19:58:12
问题 I created a converter app, I used 2 edit text one which gets input and other display output it will display output by clicking on button is there any way to get the output display in 2 edit text without using click event of button. I want to get result automatically placed in 2 edit text when we enter input in 1 edit text. EditText input,result; input = (EditText) findViewById(R.id.ip); result = (EditText) findViewById(R.id.res); // my edit texts input and result result.setClickable(false);

Android ListView with EditText values duplicating with TextWatcher

青春壹個敷衍的年華 提交于 2020-01-06 14:39:15
问题 I have a ViewHolder: import android.widget.EditText; import android.widget.TextView; public class ListViewHolder { TextView productName; EditText productStock; } And my ListAdapter (listProducts is an ArrayList of Product objects): public Product getItem(int position){ return listProducts.get(position); } public View getView(final int position, View convertView, ViewGroup parent){ View row; final ListViewHolder listViewHolder; if(convertView == null){ LayoutInflater layoutInflater =

How to set Default Cursor position to right of EditText

白昼怎懂夜的黑 提交于 2020-01-06 12:42:00
问题 I have implemented an EditText where I wanted text to start from it's right, and I achieved by set gravity = right But the default cursor still shows up at the left of my text. This is what I have tried so far : and style sheet code for EditText Field. <style name="_style_user_profile_editText" parent="@android:style/Widget.EditText"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:layout_weight">1</item> <item

How to set Default Cursor position to right of EditText

一个人想着一个人 提交于 2020-01-06 12:41:27
问题 I have implemented an EditText where I wanted text to start from it's right, and I achieved by set gravity = right But the default cursor still shows up at the left of my text. This is what I have tried so far : and style sheet code for EditText Field. <style name="_style_user_profile_editText" parent="@android:style/Widget.EditText"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:layout_weight">1</item> <item