android-edittext

Getting values of edit text error NULLPOINTER why? [closed]

戏子无情 提交于 2019-12-02 15:06:08
I'm trying to get text from values of edit field showed on a dialog and save it in a variable. final Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.dialg); dialog.setTitle("Title..."); dialog.show(); Button dialogButtonCancel = (Button) dialog.findViewById(R.id.cancel); // if button is clicked, close the custom dialog dialogButtonCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss();}}); Button dialogButtonOK = (Button) dialog.findViewById(R.id.OK); //**********************************************************************

Android Multiple EditText fields in a ListAdapter

人走茶凉 提交于 2019-12-02 15:05:24
问题 I have a screen (see picture) that is populated by a GridView using a custom extension of BaseAdapter. When the user enters some text into the EditText fields, the text they entered is liable to shifting around or disappearing entirely. I'm assuming this has to do with the recycling of views, but my understanding of listadapters is poor. The fields behave fine initially thanks to the Manifest entry android:windowSoftInputMode="adjustPan", but they shift around if you scroll chaotically. All I

Saving EditText and retrieve it automatically

房东的猫 提交于 2019-12-02 14:03:53
hi I'm trying to save the EditText widget values in the internal memory of the phone/tablet so that they can be retrieved automatically by the app when it closes or the activity stops. All off this will work using a save button.(The values of the widget are inputed by the user). You should use the shared preference ,shared preference is used to store the data in locally app whenever need you can access it . use this link https://www.journaldev.com/9412/android-shared-preferences-example-tutorial to use it. after on button click you can get the value . its help me If you want to save single

Get Emoji Count In String

て烟熏妆下的殇ゞ 提交于 2019-12-02 13:59:44
问题 I would like to find how many emojis the user has input into an EditText . If the user only enters emojis, and uses 3 or less, I want to be able to display that string within the app with a larger font. Right now I did come across this post which does help detect if emojis are present in the string, but I have not been able to figure out how to count the number of emojis. Detecting if a character in a String is an emoticon (using Android) Does anyone know how I can get the emoji count from a

How to hide Android Soft Keyboard? [duplicate]

你说的曾经没有我的故事 提交于 2019-12-02 13:44:07
This question already has an answer here: Close/hide the Android Soft Keyboard 96 answers I have two EditText Views and a Button in Linearlayout. After Completion of writing in the edittext, I want to hide the Android Virtual keyboard, How can I do that? Lucifer You may use the InputMethodManager class like this: InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow( yourEditText.getWindowToken(),InputMethodManager.RESULT_UNCHANGED_SHOWN); 来源: https://stackoverflow.com/questions/22404302/how-to-hide-android-soft-keyboard

Save multiple EditText values using SharedPreferences

拈花ヽ惹草 提交于 2019-12-02 13:27:56
I'm trying to build an app where someone can fill in their personal data like their name, telephone number, Email... For each field mentioned above, I created an EditText . Now my goal is to save the user's input using SharedPreferences so that he/she don't have to fill it up every time they reopen the app. The codes I've found take care of saving the data for one EditText only ( Save entered text in editText via button ). How can I achieve that on multiple EditText fields? This is my XML file below: <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com

EditText.getText().toString() crashes

守給你的承諾、 提交于 2019-12-02 13:12:07
问题 In my android application , I have 3 dialogue boxes in which the user puts info into 3 editTexts and it will display the one of the data onto another class/page after it randomly picks which data to choose. This is my mainClass public class MainActivity extends Activity { //Variables are displayed in this area String choices[] = new String[3]; //EditText editText; //EditText editText2; //EditText editText3; Button mainButton ; Random rand = new Random(); int finalChoice; String displayChoice

Custom ListView adapter. TextChangedListener calls for wrong EditText

心不动则不痛 提交于 2019-12-02 12:02:01
问题 I have the list of travelers with custom adapter what consist two EditText - edtFirstName and edtLastName. I want when user enters text save changes to List, and when next button click send this List to another activity. My code: public class TravellersAdapter extends BaseAdapter { private List<Traveler> itemsList; private LayoutInflater inflater; private Activity context; public TravellersAdapter(Activity context, List<Traveler> itemsList) { super(); this.itemsList = itemsList; this.context

How to display, on MainActivity, the number inserted on a custom alertDialogFragment with EditText?

喜你入骨 提交于 2019-12-02 11:16:26
问题 I'm using a custom alertdialog with an editText to insert a number, the alertdialog is working, but nothing happens when I click positive button, it should display the value inserted, in main_activity.xml . It seems that my interface is not working. I don't know what I'm doing wrong, here is my code: TestAlertDialogFragment.java public class TestAlertDialogFragment extends DialogFragment { // Use this instance of the interface to deliver action events TestAlertDialogListener mListener; public

How do a simple calculator in Android? How to do it using Buttons and single edit text?

旧城冷巷雨未停 提交于 2019-12-02 10:46:28
I am learning Android so I want to keep things simple. I have to add two numbers and display the result in a single editbox. To add with the second number you have store the first number in a variable. Then later add using this variable with the second number in the edit text. If you look at the xml and Java Code below you will have a better idea. Thanks in advance. <?xml version="1.0" encoding="utf-8" ?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <RelativeLayout