Focus out in the DialogFragment android - android

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.

Related

Android with Xamarin EditText is unusable after being set as focusable

I have a series of dynamically generated EditTexts in an Android Activity. They are generated based on the below XML:
<?xml version="1.0" encoding="utf-8"?>
<EditText
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/customEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:cursorVisible="true"
android:textCursorDrawable="#null"
/>
In some circumstances I want to disable them but let them remain visible. I am doing this by setting their focusable property to false (I have reasons for using focusable instead of enabled):
if (view2 is EditText)
{
((EditText)view2).Focusable = false;
}
When I want to reenable the EditText I set the focusable property to true:
foreach (EditText disEditText in m_disabledEditTexts)
{
disEditText.Focusable= true;
}
However, this does not make the EditText respond to the user touching it. I have spent all morning fiddling with this and I haven't been able to solve it! How can I make the EditText responsive again after setting focusable to false.
If the EditText does not have focusable set to false it works fine.
This is written in C# / Xamarin.
You need to also add the FocusableInTouchMode property so it can be focused again in touch mode. Thus said, you should probably set FocusableInTouchMode to true after you've set Focusable to false.
Focus Handling
The framework will handle routine focus movement in response to user input. This includes changing the focus as views are removed or hidden, or as new views become available. Views indicate their willingness to take focus through the isFocusable() method. To change whether a view can take focus, call setFocusable(boolean). When in touch mode (see notes below) views indicate whether they still would like focus via isFocusableInTouchMode() and can change this via setFocusableInTouchMode(boolean).
Focus movement is based on an algorithm which finds the nearest neighbor in a given direction. In rare cases, the default algorithm may not match the intended behavior of the developer. In these situations, you can provide explicit overrides by using these XML attributes in the layout file:
nextFocusDown
nextFocusLeft
nextFocusRight
nextFocusUp
To get a particular view to take focus, call requestFocus().
Reference: http://developer.android.com/reference/android/view/View.htm

Android - EditText error changes position on keyboard open/close

I am using editText.setError() attribute but the onKeyboard open/close the error float message changes position to be many pixels higher than the editText instead of being right under it.
I have added:android:windowSoftInputMode="adjustPan" to the activity at the manifest file and at the EditText xml.
How can i fix it?
Yeah,that's your xml maybe some error.you can Modify the layout ,mostly the edittext layout group ,you should change the background to transparent bellow the windowSoft. In a word ,take notice the layout ,Clever use of transparent at the bottom .

How fix error design Edittext

I design with android 4.0.3: theme.holo
When i change back color of edittext,It show lines is black color at first edittext.
How do hides black line of edittext when change background color?
Watch image: Click Here
you should be able to use
android:cursorVisible="false"
in your xml or
editTxt.setCursorVisible(false);
from java
EDIT:
Use an OnFocusChangeListener on the EditText to get a callback when it gets and loses focus and use the setCursorVisible() method to set the cursor to whichever state you need.
you can set android:textCursorDrawable="#null" in your layout

Android NumberPicker without blinking cursor

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

Using inputType on a TextView in a list item layout

I've made a ListActivity. I have an xml file that defines the layout for this Activity. I also have an xml file that defines the layout for an item in that list. This item layout has 3 TextViews inside of it. If I add the inputType="text" property to one of these TextViews, the onListItemClick handler no longer executes when I run my application in the emulator.
I noticed that singleLine="true" was deprecated, which is why I switched it out for inputType="text". Does anyone know why this is happening?
Note: I'm developing against 2.1
Thanks for your help
Setting an inputType probably causes the TextView to be focusable , and when you have a focusable element in a ListView row, the row is no longer clickable.
InputType has to do with users entering text. The equivalent to singleLine="true" would be lines="1", not inputType="text"
I had the same problem. I had resolved this issue by making textview's property focusable, false.
android:focusable="false"
Hope this would be useful to someone, as singleLine property is deprecated and inputType text is preferred.

Categories

Resources