android-edittext

Set focus on spinner when selected in android

三世轮回 提交于 2019-12-19 02:05:10
问题 I have a vertical scrolling layout with multiple EditText and Spinner controls. Problem is when i choose any spinner option after selection the screen scrolls back to the last EditText is was editing before this spinner. The Focus remains with the last EditText i was editing. Is there a way i can keep focus with the current selected spinner. I am looking for a solution that can be implemented on all spinners from layout XML or some generic method to apply to all spinners. 回答1: Here's my

Set multi-line for EditText's HINT

北慕城南 提交于 2019-12-19 01:38:12
问题 I know that I could change the No. of lines for EditeText's Text, yet could I change that of EditText's hint as well? I could not find a solution online. Thanks for the help. My Code: @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.property_search, menu); super.onCreateOptionsMenu(menu, inflater); final MenuItem searchViewMenuItem = menu.findItem(R.id.action_search); mSearchView = (SearchView) searchViewMenuItem.getActionView(); int

Hide keypad in android while touching outside Edit Text Area

有些话、适合烂在心里 提交于 2019-12-18 21:12:11
问题 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. 回答1: Code to dismiss Softkeyboard is below: public static void hideSoftKeyboard(Activity activity) { InputMethodManager inputMethodManager =

How can I remove all default padding from EditText?

China☆狼群 提交于 2019-12-18 19:19:30
问题 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

EditText: Differentiate between text change by setText() or by keyboard input

耗尽温柔 提交于 2019-12-18 19:06:58
问题 I have an EditText View which is edited by setText() from my code and by the user via (soft/hard) keyboard and - if possible by speech input. I want to handle input made by my code in another way than normal user input: if a user input happens, a internal event shall be fired. But I don't know how to differentiate between both. Previously - when developing on the emulator - I used the onKeyDown() method to catch user input. However, when testing on a real device, I found out, that onKeyDown()

Align ImageView with EditText horizontally

♀尐吖头ヾ 提交于 2019-12-18 13:35:57
问题 I'm trying hard to find a way of aligning an EditText and an ImageView properly on Android. I keep getting this result: The XML part is quite simple: <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <ImageView android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center" android:scaleType="centerInside" android:src="@drawable/android" android:visibility="gone" />

How to send key event to an edit text

做~自己de王妃 提交于 2019-12-18 13:05:11
问题 For example, send a backspace key to the edit text control to remove a character or send a char code like 112 to append a character in the edittext control programmatically. Actually, I need a method like void onKeyReceived(int keyCode) { // here I would like to append the keyCode to EditText, I know how to add a visible character, but what about some special keys, like arrow key, backspace key. } 回答1: To send a simulated backspace key press to an EditText you have to send both key press and

How to send key event to an edit text

為{幸葍}努か 提交于 2019-12-18 13:04:11
问题 For example, send a backspace key to the edit text control to remove a character or send a char code like 112 to append a character in the edittext control programmatically. Actually, I need a method like void onKeyReceived(int keyCode) { // here I would like to append the keyCode to EditText, I know how to add a visible character, but what about some special keys, like arrow key, backspace key. } 回答1: To send a simulated backspace key press to an EditText you have to send both key press and

Disable Button when Edit Text Fields empty

做~自己de王妃 提交于 2019-12-18 12:55:19
问题 I have two text fields and a Button. I want to disable the Button unless both EditText-Fields are not empty. I tried many solutions here at stackoverflow, but they don't work. Here is my code: import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class RegisterActivity

android progressbar inside edittext

為{幸葍}努か 提交于 2019-12-18 12:17:20
问题 I want to display progressbar(spinner) to the right of editText when activity is doing some processing and hide upon completion, is there a simple way to do this? 回答1: I'd use RelativeLayout , something like this: <RelativeLayout> <EditText android:id="@+id/the_id"/> <ProgressBar style="?android:attr/progressBarStyleSmall" android:layout_alignTop="@id/the_id" android:layout_alignBottom="@id/the_id" android:layout_alignRight="@id/the_id"/> </RelativeLayout> 回答2: Try this... <LinearLayout