android-edittext

How to implement DoubleClick on Android EditText?

一个人想着一个人 提交于 2019-11-30 19:27:25
问题 I have an "Activity1" which has an "EditText". I want to open another activity "Activity2" when the user Double clicks on the "EditText". 回答1: 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

How can I prevent the cursor from resizing in an EditText (MultiAutoCompleteTextView) after I add an imagespan using a SpannableStringBuilder?

自作多情 提交于 2019-11-30 19:17:35
问题 Here is what it looks like in the beginning when I haven't added any imagespan chips - As you can tell there the cursor is placed at the right size and the gravity is respected. Then when I add an imagespan, the cursor all of a sudden becomes bigger like this - I don't understand why this happens and I also don't know how to fix it, i.e. keep the cursor the same size. Finally when I start typing again, the cursor is all wierd while maintaining the size of the of the font and the span also

How can I remove all default padding from EditText?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 18:46:31
I am using an EditText and it always adds a bit of padding in my text to both left and right. Adding android:includeFontPadding="false" did not help and using negative android:layout_marginLeft or android:layout_marginRight just makes the EditText "expand". How can I strip all padding from the EditText that is being added by default? <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="20dp" android:fontFamily="roboto-regular" android:layout_gravity="center_vertical" android:gravity="center_vertical" android:layout_marginLeft="-5dp" android

Hide keypad in android while touching outside Edit Text Area

好久不见. 提交于 2019-11-30 18:36:59
I know that the code for dismiss tyhe keypad in android is InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0); Can anyone suggest me a method to hide the keypad if we touch the area outside the text area other than the keypad in the screen. Sharmilee Code to dismiss Softkeyboard is below: public static void hideSoftKeyboard(Activity activity) { InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE); inputMethodManager

How to change the color of the line in ICS styled EditText

纵然是瞬间 提交于 2019-11-30 18:26:53
问题 I and using ABS together with theme holo in my application and i get EditText styled as if in ICS. But the line color of the EditText is blue by default and for my design, i need white colored line for the EditText. I tried changing the background, but it is not working. Is there any way so that I can change the color from blue line to white programmatically? 回答1: I found the answer in this link where they are using LayerList I used a layer-list for creating an ICS styled edittext as it was

Extending a EditText in Android. What am I doing wrong?

最后都变了- 提交于 2019-11-30 18:05:51
So I'm trying to get a grasp of using custom controls in Android. But my app crashes on trying to create the activity. Here's the code: package com.myApp; import android.content.Context; import android.widget.EditText; import android.view.View; import android.view.View.OnClickListener; public class MyEditText extends EditText implements OnClickListener { public MyEditText(Context context) { super(context); // TODO Auto-generated constructor stub } public void FlashBorder() { //do some custom action } @Override public void onClick(View v) { // TODO Auto-generated method stub EditText txt =

Positioning EditText Above Keyboard

十年热恋 提交于 2019-11-30 17:27:49
I have got an EditText looking like this (with "bottom gravity"): When I press the EditText , the keyboard shows up and I can't see anymore what I'm typing (because the EditText is now behind the keyboard, on the bottom). How could I move the EditText automatically just above the keyboard, when it has been pressed? At the end, it would be good if it would look like this: My Code: // LINEAR LAYOUT LinearLayout layout = new LinearLayout(getApplicationContext()); layout.setOrientation(LinearLayout.VERTICAL); setContentView(layout); // TEXTVIEW layout.addView(tv); // EDITTEXT et.setGravity(Gravity

Android: Edittext- get current line

徘徊边缘 提交于 2019-11-30 17:23:40
问题 In an edittext is there a method for getting the current line of the cursor? If not I will write my own method, but just wanted to check. If I do write my own method would the best method be to go through every character in the edittext until selectionstart and count the number of \n's using a For loop, or is there a better way? Thanks! 回答1: Just to let people know: There is a better way to do this then Doug Paul has suggested by using the getLineForOffset(selection) : public int

Android : Multi line text EditText inside BottomSheetDialog

邮差的信 提交于 2019-11-30 17:20:36
问题 I have a bottom sheet dialog and exists EditText in layout. EditText is multiline, max lines is 3. I put : commentET.setMovementMethod(new ScrollingMovementMethod()); commentET.setScroller(new Scroller(bottomSheetBlock.getContext())); commentET.setVerticalScrollBarEnabled(true); but when user will begin scrolling text of EditText vertically BottomSheetBehavior intercept event and EditText will not scroll vertically. Anybody know how to solve this problem? 回答1: Here is an easy way to do it.

Create a multiline EditText programmatically

二次信任 提交于 2019-11-30 17:12:37
I am trying to create a multiline EditText by code. This is what I use: EditText txt = new EditText(this); lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1.0f); txt.setLayoutParams(lp); txt.setSingleLine(false); txt.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE); But it is still in one single line. This should do it txt.setSingleLine(false); txt.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION); You may also use this: txt.setInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_FLAG_MULTI_LINE); Combining all above answers was the correct answer