android-edittext

Creating EditText Dynamically in Android

ぃ、小莉子 提交于 2019-12-20 10:23:58
问题 I am working on a application where I have to create multiple EditText and Spinner dynamically. So I started looking for the solution as I don't have permission to use Invisible property in XML file. I searched a lot and got a very few examples only on stackoverflow . I follow them and created this program. **MainActivity.java code** public class MainActivity extends Activity { RelativeLayout containerLayout; static int totalEditTexts = 0; Button button; Context context; @Override protected

How to change the default disabled EditText's style?

偶尔善良 提交于 2019-12-20 09:18:10
问题 It isn't looking nice when using EditText enabled="false". How can I change it automatically for all of the controls? I've added this image for reference. Can someone help me? Thanks. 回答1: In the color file define your color: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="false" android:color="@color/disabled_color" /> <item android:color="@color/normal_color"/> </selector> In the layout: <EditText

Detect if content of EditText was changed by user or programmatically?

时光总嘲笑我的痴心妄想 提交于 2019-12-20 08:48:28
问题 I would need a way to detect if the EditText has been changed by the user typing something or by the app changing the text programmatically. Any standard way of doing this? I guess I could always do something hackish like unsetting the TextWatcher before setText() and setting it back again afterwards, but there's got to be a better way of doing this... right? I tried checking if the EditText is focused in the TextWatcher, but that was of little help since the EditTexts gets focused "semi

How to clear focus for EditText?

我们两清 提交于 2019-12-20 08:28:12
问题 I have an activity with a search box ( EditText ) on the top, and a ListView below. Whenever the activity starts, the EditText always has focus and bring up the keyboard which partially cover the ListView . There's no other text view that can have focus. I want the EditText to have focus ONLY when the user touches it and start typing. I try to put clearFocus() in onCreateView , onViewCreated or onCreated , but no luck. 回答1: Set in your parent layout next attributes: <RelativeLayout xmlns

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

穿精又带淫゛_ 提交于 2019-12-20 07:55:57
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . 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

EditText in a list aren't working the way they should

十年热恋 提交于 2019-12-20 07:37:18
问题 I have a problem with EditText fields in a ListActivity . The code complies all right, but the functionality is strange, typing in the first field and hiding the keyboard after this the text appears in another editfield. Help me with my logical issue package com.example.helloandroid; import android.app.ListActivity; import android.content.Context; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget

Change text from other activity

北慕城南 提交于 2019-12-20 06:39:39
问题 I want to change the contents of an EditText on another Activity with a button. Both activities extend from the same parent. How can I do this? 回答1: i recently started learning about java events and listeners. I believe my SO question may help you. Here is the link to my question. Basically what you can do is set up an event for when they press the button and then have a listener and have the listener trigger the change. Take a look at my question for more detail. If you take a look at the

Android listview with editText and checkbox for each element

主宰稳场 提交于 2019-12-20 06:25:54
问题 let's say that i have a list of items and i want to build a form with each of these items. This form consist of two checkboxes and an editText. For example i want to know if each item is present in a warehouse and its quantity. I'm thinking for solving my problem to use a listview where each element of my listview will consist of the name of an item, two checkboxes and an editText. The problem is that the only use of listview i know to present list of elements, i don't how to solve my problem

how to toast a message if editText is empty by clicking button?

我的梦境 提交于 2019-12-20 04:51:27
问题 i have 2 edit Text in my application, 1 button to add the input numbers in the edit Text and 1 text view to display the result. I would like to put a toast message if my edit text tab is empty or null when i click the button. I have searched and tried all the solutions..and nothing seems to work. help please!! here is my code for adding the two numbers. MainActivity.java package com.example.mycalc; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android

Get integer value from edittext

狂风中的少年 提交于 2019-12-20 04:42:07
问题 When I try to run the code below, my program has stops. I want this code to get the value from edittext but it´s not working as I expected it. What am I doing wrong? public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button sum = (Button) findViewById(R.id.button1); Button cancel = (Button) findViewById(R.id.button2); final EditText from = (EditText) findViewById(R