I have a button and as a background, I have an image selector which reacts on press event. The button's text is a spannable string which may contain some links or phone numbers. I linkify those links and phone numbers but how to pass further onClick event to button's text to open browser when I tap over a link?
The button is not designed to work that way. I would use a text view and manipulate background, so when the user cliks on the link the background changes and with some delay changes back and only then open the web link.
Related
I have a button with 2 states, start and stop. In accessibility mode using TalkBack when the user double-taps the button I change the text of the button to stop so I must say to TalkBack in some way that this happened. I managed to achieve removing and readding focus to the button with following:
button.performAccessibilityAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS, null);
// This works for the focus but doesn't make TalkBack speak. button.performAccessibilityAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
// Needed for TalkBack to speak.
button.performAccessibilityAction(AccessibilityNodeInfo.ACTION_SELECT, null);
The problem with this is that TalkBack will only read the content description, but not say "double tap to activate" which gets read when you select the button manually.
Following didn't work:
button.requestFocus();
button.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
button.clearFocus();
button.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED);
Maybe somebody has a hint what am I missing?
In your clickListener use announceAccessibility
For my first Android app I have (hopefully) followed the tutorial at developer.android.com to the letter. The finished app has an EditText view where you can enter text and a SEND button which will open a new activity (DisplayMessageActivity) which displays the text in the EditText in large font.
I have noticed some inconsistent behaviour regarding the persistence of the text in the EditText. Assume I have entered some text there:
When I hit the Back button at the bottom of my phone and restart the app from the icon I loose the text.
When I hit the Home buttom at the bottom of my phone and restart the app from the icon I keep the text.
When I press the SEND button and leave the DisplayMessageActivity via the Back button at the bottom of my phone I keep the text.
When I press the SEND button and leave the DisplayMessageActivity via the arrow button in the action bar I loose the text.
Can anyone explain to me why the behaviour is different and what I have to do to retain the text in all four cases?
I have a EditText in my activity. I want that when the user finish the text, he can move to the next activity without press back button to hide the keyboard. I was wondering if there a way to put a button on softkeyboard to move to next activity.
(Sorry for bad english, its not my native language)
You can't add buttons to an existing keyboard. However, you can suggest a label and id for the custom IME action. See TextView.setImeActionLabel:
Change the custom IME action associated with the text view, which will be reported to an IME with actionLabel and actionId when it has focus.
You'll then have to call TextView.setOnEditorActionListener to provide a custom listener to listen for that IME event where you can then move to your next activity.
I have a bar in my app with 2 buttons side by side. One button represents the page the user is currently on and the other redirects the user to another page with the same button bar. What I want is for the button that represents the page the user is currently on to look like it is pressed (i.e. the color it would be if it is pressed). I already have it set so it can't be clicked. Is there a setting or attribute or do I HAVE to create my own selector (because I don't really understand how to implement that)?
Have never tried this but
button.setPressed(true)
should work.
Edit: You can also add
button.setClickable(false)
Edit: This does work but the order is important. Use this
btn.setClickable(false);
btn.setPressed(true);
I have an OptionMenu which has single option in it named "Search". When the search option is clicked, it should dynamically add a EditText at the top of Activity window like it has in WebView (browser address bar) so users could search something in my application.
After there would be EditBox, one can write inside it. I also want to have some OnTextChanged like event of that EditBox so do you think it's also available with that View?
I made it myself. I added an EditText on the screen with setting as hidden and on button click made it visible. It worked like a charm.