I'm using the NumberPicker under the Android SDK level 13 inside a fragment. Works fine, but each time the activity is started the cursor is blinking behind the number. How can I get rid of the blinking cursor, I don't know why this widget has the focus.
This is the xml of the NumberPicker:
<NumberPicker android:id="#+id/timer_picker_hrs"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
I get this solution from somewhere but I don't remember from where. This works good for me,
just do this in your activity.
myNumberPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
You can also set this in XML:
android:descendantFocusability="blocksDescendants"
(Borzh comment)
One way of removing the blinking cursor is disabling the soft keyboard for the NumberPicker. (refer to: Disable soft keyboard on NumberPicker )
It's gaining focus because of child CustomEditText
you need to move focus to other view or disable soft input
se my answer for solution:
how disable focus on NumberPicker
Related
How can I disable spelling corrections in an EditText's soft-keyboard programmatically in Android? The user can disable it from settings, but I need to disable it in my application.
Is there any way to do this?
Set this in your layout's xml for your EditText:
android:inputType="textNoSuggestions"
Or call setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) in your Activity'
If you need to support API 4 and below, use android:inputType="textFilter"
If setting:
android:inputType="textNoSuggestions"
still doesn't work (and your text field is small), a quick work-around is to use:
android:inputType="textVisiblePassword"
I created DialogDragment with several TextEdit. I didn't set focus in xml and java files. But when I call show method and dialog appear I see that focus set in the first text field. How to hide the focus ?
You can set the focus on the surrounding layout instead. by using these attributes:
android:focusable="true"
android:focusableInTouchMode="true"
This will cause the focus to be set on the layout, and not in the EditText.
I'm a newbie in Android development. Recently I have been facing a problem in the EditTexts(eventhough I havent changed any attributes of EditText) used in my app which I'm currently running in Emulator.
On clicking the EditText it receives focus, but on typing something the focus changes to some other view. But I'm able to enter values if I navigate to EditText using Tab button of the keyboard. This happens to all EditTexts in my application.
Surfed net for getting a solution, but did not find one.Help...
Implementation of one of my EditText:
<EditText
android:id="#+id/edittext_testname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/hintEditText1"/>
Thanks in advance.
Ever tried your app on a physical device?
However, I cannot see anything wrong with your EditText xml. Perhaps there is some java code in your activity catching any events related to that EditText? Or maybe to the other view element you mentioned getting the focus?
I had a similar issue but with a custom style I had defined for my EditText. How I fixed it?
<item name="android:focusable">true</item>
<item name="android:focusableInTouchMode">true</item>
So try applying the "android:focusable" and "android:focusableInTouchMode" properties and see if it makes any difference. They should be applied to the EditText by default but give it a go.
(I would have posted this as a comment but I need more rep)
I am designing a Tab based Android application and using Fragment. My first fragment Layout have few Edittexts and on navigating to other fragment which don't have any EditTexts, on tap is getting Virtual keypad to appear. And after few hours of testing, I found its caused by the EditText which is in the previous fragment. How to prevent this ?
Use this in ur activity where you dont want a virtual keyboard
activity=this.getActivity();
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftkey(activity.getCurrentFocus().getWindowToken(), 0);
#Joseph, Try to mention the efforts and implementation you have achieved up till now, this helps to point out the error or a mistake. For your question, try to set the focus of the layout you want to interact with. This may help you to have a requestCall()
Also check this:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Here is how you can set focus in XML. Put this code within the tag of the control you want the focus on when starting the application.
<requestFocus
android:duplicateParentState="true"
android:focusable="true"
android:focusableInTouchMode="true" />
I have a problem with TextEdit,
if I do editText.setInputType(InputType.TYPE_NONE); the user is not able to type anything.
Anyway, if there is a physical keyboard attached, then the user can type by using it (of course the soft keyboard doesn't work).
Is there any way to fully disable editing on a EditText?
PS: I need to do that programmatically at runtime
Try
android:editable="false"
in xml layout file
android:editable="false" is deprecated ,prefer not to use it.
Another solution to this that I used is given below
first_password_EditTextBox = (EditText) findViewById(R.id.editText1);
first_password_EditTextBox.setEnabled(false);