I have an editText that contains a drawableRight property. This editText is a search field, and the drawableRight is an "x" icon for clearing the text from the search field. When using Talkback (screen reader), I can't select the drawableRight to trigger my onTouch() event as it thinks I'm trying to tap on the editText as a whole.
I've tried to use .sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED) on my editText drawable, but accessibility functions can only be used on elements that inherit from View.
When I try to access the drawable like this editText.getCompoundDrawables()[4] it doesn't give me any accessibility options, as it does not inherit from View.
I need to find a way to let people with disabilities be able to tap on the "x" drawable from my edit text to clear the search bar text.
Related
I want to set dynamic text to my edit text from the custom keyboard.
For example if I press "a" from the my keyboard then I want to set clipboard data to my edit text.
I use following demo for custom keyboard,
https://github.com/blackcj/AndroidCustomKeyboard
And it work perfect, but I want to just customize it, I want to override my functionality on it, if I am press any of alphabet then I want to perform my action on application edit text.
Please suggest how to do this , and this is possible to paste my clip board data to edittext from the my custom keyboard any key event?
You should have call back method for each key pressed by user, so you can set your custom test to edit text.
You must have class that extends InputMethodService which overrides onKeyDown method where you can write code to set custom text to edit text based on key pressed by user.
I want have EditText and clear button(to the right of the EditText)to clear the text in the EditText and also want to implement accessibility on both of the elements.I can do in following ways :
By adding clear button as drawable right in the EditText.
By adding clear button as the separate button to the right of EditText in the layout.
I am keeping 2nd way as the optional if its not achievable by first way.I want know to if it is possible to have EditText and drawable right (clear button)to it and make both EditText and drawable accessible (ie when accessibility is on i want to first focus on EditText and then when in swipe or navigate focus should go to drawable clear button).
Thanks.
I'm using the AutoCompleteTextView to allow users to search a from a list of countries. I want to have some default text preloaded in the search bar before the user clicks on it, such as "Search" or "Find Nearest Country". Is it possible to do this? If so how?
Right now, the app opens directly into the search box with the keyboard pulled up. Rather, I want the users to click on the bar before searching.
http://developer.android.com/reference/android/widget/AutoCompleteTextView.html
A TextView's hint seems to be exactly what you need. See android:hint for the XML attribute or setHint() for the corresponding Java method.
To prevent the keyboard from popping as soon as your activity is entered, you should set the android:windowSoftInputMode attribute in the activity declaration to stateHidden.
I'm implementing a custom search bar in my Android application. This search bar is just an EditText with a magnifier set to leftDrawable property. My problem is that I don't know how to get noticed when the user clicks the magnifier. Is there any listener for doing this? Am I using the recommended approach to implement this search bar? I know I could use an EditText and an ImageButton on its right side, but I want the magnifier to be inside the EditText.
Is there any listener for doing this?
Not specifically for that image.
Am I using the recommended approach to implement this search bar?
I am not aware that there are recommendations for implementing a search bar. It is not the way Google elected to implement a clickable button for their search bar, which has the button to the right of the field.
You may be able to have the desired effect by:
Putting the EditText in a RelativeLayout
Adding a transparent View as a later child of the EditText, sized to match the size of your image
Using margins to have the transparent View be over top of your image
Setting an OnClickListener on the transparent View
I would like to have an EditText with one modification: on the right but still inside the EditText there should an arrow pointing downwards that I can set OnClickListener to so that when the user clicks on the arrow it displays a menu.
What is the best way to do this?
Do you mean something like this ?
see image
Add the arrow by setting the drawable right attribute
android:drawableRight="#drawable/right"
to your EditText. Then you would need to set an OnTouchListener to get the events.
I did this by putting EditText and a Button into RelativeLayout, the Button (which has custom background drawable) is overlapping the EditBox.
When user clicks on it, the EditBox doesn't receive the click event.
Sounds like a combo box. If you look at the "Building Custom Components" section of the Dev Guide, they mention combo box briefly, but give details on how to build any custom component.