android-edittext

getText from a EditText in a DialogFragment

喜欢而已 提交于 2019-12-01 02:25:27
问题 I have a DialogFragment like this one The Dialog is called by clicking on the "plus" button in the MainActivity below which is initially empty. When I click on "continue", I create a button and so far it works. I also wish that the string I insert in the EditText in DialogFragment is shown on the button I've just created. My problem is that I can not retrieve the string I entered in the EditText. Here is the code: MainActivity public class MainActivity extends FragmentActivity implements

Android Development: How Can I Make An EditText Plain So It's Just A White Square?

徘徊边缘 提交于 2019-12-01 02:15:04
问题 As the title says, I've seen EditTexts where they are just plain white with no smooth corners or orange android border when you highlight it etc. Like it looks in this app: http://s1.appbrain.com/screen?id=-2631427781674403509&i=1 回答1: You need to create a custom background 9-patch image like this one and put it to /res/drawable directory. Here is the tutorial for 9-patch images. Then you need to apply the image as a background for your EditText using android:background attribute. Here is a

Which theme attribute changes the text color of an EditText's error message

て烟熏妆下的殇ゞ 提交于 2019-12-01 02:14:29
In my form I use setError("") on an EditText field. My Application-Theme extends android:Theme.Holo . I have manually set an image with a dark background for android:errorMessageBackground and android:errorMessageBackgroundAbove . And now here's the problem: The text color of the error message is also very dark and not readable. I tried changing different textColor attributes in my Theme, but I wasn't able to find the correct one. May anyone could help me, please? Thank you! Chris Pradeep You can change the text color by using HTML Font Tag. But for customizing background color, you should

How to get URL from String on Android

人走茶凉 提交于 2019-12-01 01:52:28
I'd like to extract URL from hi there this is a URL String http://mytest.com . I tried to use EditText.getURLs but it didn't work for me. EditText.setText("hi there this is a URL String http://stackoverflow.com"); EditText.getURLs.toString(); How can I get URL from EditText? Here is the function: //Pull all links from the body for easy retrieval private ArrayList pullLinks(String text) { ArrayList links = new ArrayList(); String regex = "\\(?\\b(http://|www[.])[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|]"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(text); while(m.find

How to dynamically add edittext to android

喜欢而已 提交于 2019-12-01 01:36:24
I want to add edittext dynamically to the android display. I want to make something like in the android contacts where you can dynamically add fields and remove them if you dont need them. Thank you for your help See Everything dynamically TextView tv=new TextView(this); tv.setText("TaskID"); TextView tv1=new TextView(this); task=new EditText(this); task.setMaxWidth(100); task.setMinHeight(100); tv1.setText("Task"); id=new EditText(this); id.setMaxHeight(10); TextView tv2=new TextView(this); name=new EditText(this); name.setMaxHeight(1); tv2.setText("Name"); LinearLayout l=new LinearLayout

How to make edit text error position in android?

纵然是瞬间 提交于 2019-12-01 01:29:28
I have an app in which I have edit text fields in which I have to enter a mobile number and password. The problem is that the EditText error indicator covers the mobile number and password filed, and the user will not be able to enter mobile number. How do I solve this? Use this android.support.design.widget.TextInputLayout . which can show the error below to the Edittext .so You can easily write next thing like your number and password in the new Edittext . Here is xml code : <LinearLayout android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_marginTop="?attr

android prevent EditText from requesting focus automatically

柔情痞子 提交于 2019-12-01 01:21:41
问题 I have a quite simple Layout with an EditText and a button. The problem is the keyboard appears immediately after the activity is started and the EditText gets the focus. I removed the </requestFocus> from XML and I also don't do that in code. How can I prevent that behavior of EditText so the keyboard only appears after the used taps the editText? 回答1: in your manifiest.xml write the below code in your activity android:windowSoftInputMode="adjustNothing" 回答2: In your manifest.xml file, under

Android: Multiline & No autosuggest in EditText

人盡茶涼 提交于 2019-12-01 00:59:18
问题 Is it possible to have an EditText that allows multilines and doesn't show the suggestions? I tried with this code: android:inputType="textFilter|textMultiLine" Which I saw in this question, but it didn't work for me. If I try to use both at the same time, the EditText supports multiline, but the suggestions appear. Separately, they work properly. Is this a bug in the SDK? Or maybe it is not possible to combine them? Thanks! 回答1: This is supposed to do what you want: android:inputType=

How to implement DoubleClick on Android EditText?

坚强是说给别人听的谎言 提交于 2019-12-01 00:47:09
I have an "Activity1" which has an "EditText". I want to open another activity "Activity2" when the user Double clicks on the "EditText". Daniel Fekete Use this: final GestureDetector gestureDetector = new GestureDetector(context,new GestureDetector.SimpleOnGestureListener() { public boolean onDoubleTap(MotionEvent e) { Log.e("", "Open new activty here"); return true; } }); TextView tv = (TextView) findViewById(R.id.editTextID); tv.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { return gestureDetector.onTouchEvent(event); } }); 来源: https:/

How to disable edittext pop up when EditText is LongClicked?

点点圈 提交于 2019-12-01 00:45:45
Hello All I have used onLongClickListener() to my EditText view but whenever I click on view for long time so a popup appears that doesn't let me do my task in onLongClick(View v) . The pop up contains some options like Select All,Select Text,Cut All ,Copy All etc. I want to disable that (that should not appear on clicking long on EditText view). How can I do that please Help Me you can return true in your onLongClick listener onLongClick method? that means that you have consumed the event and it wont be passed further along. I also got that popup when I overrode onTouchEvent() and returned