I just downloaded AOSP and modified TextView for my purpose.
I have added a LongClick Listener to the TextView, which shows a simple Toast.
Since I modified the Android framework, it is reflected into all the apps and entire Android OS.
I have now run into a weird issue where the TextView is getting focus in some places and other underlying widgets are not getting any focus. This is creating lot of issues.
For eg: In Settings app, The 'Wi-Fi' text is receiving focus, but I cannot enter the wi-fi settings unless I click in any empty area in the Wi-Fi list item.
(I hope am clear!)
Another example: I am unable to select the Radio Button just because the text corresponding to Radio Button receives focus.
So my question is:
Is there any way I can make TextView non-focusable but receive Long Click events?
Is there any way I can pass the focus down to the parent layout?
Any other way you can suggest?
(PS: Please do not say what I am doing is right or wrong. It's just a feasibility test for what I am trying to achieve.)
A view does have the attributes "focusable" and "longClickable". Have you tried a combination of these?
Related
Just found myself trying to figure out this strange behavior in for EditText.
Information:
Bug seems to only happen in some devices! for now I've only seen it in Sony Xperia D2303.
App description:
I'm working on an app that has a main activity and navigation is done trough different fragments that are replaced as user moves from one section to another.
At one point I'm showing a DialogFragment with an edit text field, with background set to #null, with a hint text. (I have also tried with a normal edit text, taken from widget list and dragged to the layout and found the same behavior).
Problem:
When clicking on the EditText, software keyboard SHOWS UP but when typing there is no letter input in the EditText! I can long press, to visualize cursor position marker and also the magnifying glass shows up.
Things I've tried:
- I've tried requesting focus with xml, programmatically.
- Setting touchable(in touch mode also)
- Setting descendantFocusability attribute of parent to 'afterDescendants'
- Overriding onTouchListener and showing keyboard programmatically through the InputManager and using the edit text's token
… and maybe other things which I don't remember
There is but a workaround that I've found!!! sending the app to background, and bringing it to foreground again… so it seems something related to focus maybe?? but then why does keyboard show up, and cursor marker and magnifying glass work?
This solution does not work for me as it depends on the user taking action
Has anyone found this problem? any suggestions?
Thanks in advance!
I'm developing an application and I am facing a problem using ExpandableListView. What I'm trying to do is, in GroupHeader, not only show the group name, but also an spinner with options. That's because I want to show the football second division games in the list but, also, give the option to choose the round, in case the user wants to check older/future games. SO far I have that
As you can see both, title and spinner, shows. Also you can see the arrow on the right which is supposed to expand the list. Problem is that, if I click, only spinner opens, group expand button doesn't. So, here is my question, how can I make both of them work depending on where you click (one or another)??? Is that possible?
Also I must say that if I only place the TextView with the group name works perfect. If I only place the spinner, the problem persists. So I'm guessing that's a focus problem.
Btw: grey areas are the layout backgrounds, so no, they are not hiding behind the button.
I found the solution, I just neede to add this line android:descendantFocusability="blocksDescendants" to the Main Layout of the xml where I define the GroupHeader elements.
I am working on a notepad application for android and it seems I have a litte problem for a textview. Here's the thing: I have a listview of notes, when I click a note, I open another activity which displays the content of my note into a textview. When I click this textview(representing the text from the note), it opens another activity for editing the text (like most of these apps do). The problem is that some of the notes are really long, so I need to make my textview Scrollable. But since I am having a "setOnclickListener" on it, I cannot do that at the same time. I have searched a lot on google and apparently a lot of folks seem to have this problem. Is there a way to achieve my goal?
Ideas:
Use OnGestureListener or OnTouchListener
Use an 'edit' button
Use long press instead of OnClick
I like to recreate the behaviour of the textview containing the message of a user in the g+-app in my android project. To be exact:
- on click on a link the link is visually selected (blue selector) and will open up in the browser
- on click on normal text the whole list item is selected
The main problem I have, is, that every approach I tried to make links clickable (via xml and autolink=web, or in code) ends up, that the link opens up in a browser on click, but when I touch normal text in this textview the item is not selected (no selector is visible).
I read many threads about this issue, but all the solutions, like add setFocusable(false), etc. doesn't work for me.
So I want to ask, if there is any tutorial, how to or example, where I can see how this things work, or do you have any idea how I can get it to work?
Thanks! :)
if you have email id in textview use below code..
TextView email = (TextView)findViewById(R.id.TextView04);
email.setText("sasd asd#gmai.com sadasd");
email.setLinkTextColor(Color.WHITE);
Linkify.addLinks(email,Linkify.EMAIL_ADDRESSES);
if you have url in textview use below code...
TextView tv = (TextView)findViewById(R.id.TextView04);
tv.setText("sasd https://asd.com sadasd");
tv.setLinkTextColor(Color.WHITE);
Linkify.addLinks(tv,Linkify.WEB_URLS);
Pretty new to android so excuse me if this is a really obvious question.
Say my application has a bunch of TextViews, each one showing the attributes of a certain product (name, price, etc). I have a button next to each of these TextViews labeled "modify".
How do I make it so that when I press the modify button next to a certain attribute, a popup window with a space to enter text into comes up so that the user can enter text into this box and then have the actual attribute listing on the original page change? Actually I just need a push in the right direction with creating this popup text field... not sure if there is already some built in functionality for this or if not, what would be the best way to create this kind of thing.
Thanks.
Why not have the modify button set TextEdit.setEnabled(true); and then change focus with TextEdit.setFocus? Note that both of these are inherited from view
If you really want a dialog you might want to looking into the AlertDialog.Builder. I know you can use it with buttons and radio buttons, but I'm not sure you can get it to work with a TextView.
Use a code like this for the input popup: Android dialog input text
In the positive button handler, set your edittext content programmatically like this:
myEditText.setText(value).
As simple as that. The only difference with a standard GUI framework is that you don't retrieve the value as a result of the popup function. Instead, you must provide an action handler.