I have a stack view widget can hold a variety of items. When I select an item I want it to go to the "front" of the list. I've currently been able to implement this.
The problem I'm having, is that I can't seem to figure out how to make the StackView "reset" itself or go back to displaying item 0. So what ends up happening is the user selects an item in the widget, but when they come back they have to manually scroll the widget back to item 0 to see that item since it's moved.
Is there any way to force the Stack View widget to "advance" or "move" to position 0? I've tried numerous different methods from the documentation but none seem to do the trick.
Thanks!
Related
I have couple of issues in the process of making my app accessibility compliant.
I have a spinner with some items in it, after I select one of the item, spinner closes and focus is moving to the top of the page action bar but I want the focus to remain on the last used element i.e, the spinner. Tried:
spinnerId.requestfocus(); or spinnerId.performAccessibilityAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS,null); in the code but nothing worked.
2.How can I set the focus to last accessed element even if onResume(); is called to refresh the data ?
3.Page reverse order doesn't work all the time when I scroll back through the elements.
4.I have a listview with elements populated dynamically, accessibility doesn't scroll the page all the times instead it goes to right fragment( i have left and right fragments in my tablet) skipping the elements below the screen.
As your spinner is already focus, you have to clear this focus, send this event to Accessibility and request it again:
yourView.clearFocus();
yourView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
yourView.requestFocus();
yourView.setFocusableInTouchMode(true);
He took me awhile to find this tricks, but we used it in few different place in our app, and it work well.
I have a situation involving animation of listview's item appearances.
I have a few views in a ScollView , the last of which is the listview. I have attached an appearence animation of the row (a fade in animation).
The problem I have is that when the screen is loaded , the getView() of listview already executes for the initial items , even though the listview is not currently in view.
Hence when a user scroll downs , he sees the list plainly.
I am unsure how to go about this situation . Is there any callback that can be invoked when a row from a listview becomes visible on screen ? .
Yes there is a callback (OnScrollChangeListener), first visible index and last visible index etc. You can achieve what you are trying to using combination of these.
But you need to try that yourself first. No one can simply write a code for you.
You can learn about listview here
I need all of the other views in my arrayadapter to check their attributes and return to a default attribute at certain times
use case: listview items (a)(b)(c)(d) , when you touch (a) it's background turns black. This is done in the ontouchListener. But when you touch view (b) it's background turns black BUT (a)'s needs to turn back to the default which is not black
I dabbled around with recalling the arrayadapter at the end of the view.OnClickListener but the problem with this is that it also resets the scroll position of the view, so if this list was much longer - which it is - and user touched item (r) , then it would reset the list and put the user back at item (a) at the top
I was looking at notifydatasetchangedbut I am not sure how to use that and where it should work
insight appreciated
notifyDataSetChanged will do the job. You can call that at any time in your code and this will trigger the adapter to call getView for the visible list items again and so update their content. So basically the only thing you have to do is to update the list item states or information before calling that method.
I have 2 lists, one on the left of the screen, the other list, on the right of the screen which gets dynamically populated based on the selected item on left list.
I move to the right list by pressing "Right" key from the left list.
Issue: Whenever I press right key from left list, the item that is currently selected is the item of the right list that is currently aligned with the left item. I dont want this to happen. I always want my 1st item of the right list to be selected. Can anyone help how to go about this?
Hmm, I don't know if it will work for ListItems. But with Buttons, there is an attirbute to set where the focus must go to! Eg: nextFocusRight
However, in these, the View Id must be specified, i.e the id of the view to which the focus must be passed. So am not very sure if it maybe useful with ListView items.
link text
I am displaying a radio schedule in a List View and would like to highlight the currently playing program. I also want to allow the user to click on any program and get more details for the program. I have tried the following:
radioView.setSelection(adapter.getCurrentProgramIndex());
radioView.setSelected(true);
This does scroll the list down to the selection which is good, but it does not highlight the selection. I understand this is because the device is not in touch mode, but how then would I go about highlighting the current program?
how then would I go about highlighting
the current program?
Change something in that list row. For example, perhaps you have an icon you can switch to be a "playing" icon, or have an icon that is formerly INVISIBLE become VISIBLE, or something.
Bear in mind that you will need to have these smarts in your row binding code, so that if the user scrolls, you correct undo and redo that setting -- otherwise, row recycling will make it appear that other programs are playing.