Android ListView with a focusable elements in a row - android

I'm working on custom app for TV platform.
I need a something similar to grid view but much advanced in my app.
I need each row to be independent and to scroll independetly from others.
So I have created normal vertical ListView...and in each row I have custom horizontal list view...
Now I have the problem that my horizontal list views element can get focus from vertical list view.
Vertical list view doesn't need to be clickable, it just needs to scroll up and down and give focus to horizontal rows.
In horizontal list view elements I have the real content which is focusable and clickable..
I have tried with different paremeters setFocusable, setClicable, setFocusableInTouchMode, setDescendantFocusability...
But nothing worked, I can't get focus on horizontal list.
Also I'm not using touch events, but remote controller.
Tnx in advance!

try to override dispatchTouchEvent or onInterceptTouchEvent

Related

When we use a scroll view and Recycler view

In a app we have a activity which displays a list of textview let us take a list of numbers 1-9 or more than that.Which view is useful to display textviews either scroll view or Recycler view?
Recyclerview itself has scrollbar implemented in it. It is used when you have a large dataset.
ScrollView is used when you have a limited set of children on your UI and they are fitted out of your screen, so ScrollView is implemented here to scroll your layout to see all the children.

Disabling the scroll of listview

I have created a listview inside scrollview. Atfirst it was not scrolling but when it started scrolling then layouts below list view started disappearing from screen. is there any solution to dynamically calculated he height of list view and assign it or is it possible that some how the scrolling of listvew is disabled so that only its items appear on screen like normal layouts or any tags and it does not scrolls???
ListView is deprecated. I would suggest you to use RecyclerView and add nestedScrollingEnabled="true" to your xml or call RecyclerView.setNestedScrollEnabled(true) if you want to wrap adapterview with a scroller. You can also try NestedScrollView for support compability.
Good luck

Android list view inside a scroll view auto scroll issue

I have an android layout setup where I have a ScrollView with some elements and inside that I have a ListView. I am using StackOverflow's answer Android list view inside a scroll view for achieving this feature and it's working fine. My ListView is below some elements like TextView, ImageView. Problem is that when the page is presented ListView get scrolled automatically so that first item in listView is at the top (ie whole scrollview gets scrolled to present listview first item). How can I avoid this auto scrolling?
Add android:descendantFocusability="blocksDescendants" to child of SrollView (and parent of ListView)

What is the best way to display custom view with scrollable behaviour on android

I have to display multiple custom view with scrollable behaviour (as a grid list).
Like scrolling horizontally and vertically on a chest grid where each item is a custom view.
What is the best way to do this on android ?
ps: I have seen we can use ScrollView -> TableLayout -> row -> list of custom view
sources:
http://androiddevblog.blogspot.com/2009/12/creating-two-dimensions-scroll-view.html
http://sdroid.blogspot.com/2011/01/fixed-header-in-tablelayout.html
Android TableLayout does not scroll vertically
How to make a scrollable TableLayout?
Thanks ;)
I would look at this example.
http://developer.android.com/training/implementing-navigation/lateral.html
Look at the section labeled "Implement Horizontal Paging (Swipe Views)"
A view pager will allow you to swipe to the right and left, while having a custom view that can scroll up and down.
Even if this exact example doesn't work for you, you could probably look at the source code for view pager. All its doing is caching x number of custom views and listening for touch events to show the next view.

Merging ViewFlipper with ListView

What I'm trying to do is to have horizontal ViewFlipper and Listview, both with custom ArrayAdapters, inside LinearLayout which would be vertically scrollable on whole screen.
1) Tried adding ViewFlipper as a ListView header but then I can't use GestureListener since ArrayAdapter takes control over it like it's ListView item.
2) Tried putting them together inside LinearLayout but ViewFlipper's position is fixed and ListView is scrollable inside rest of the screen.
3) Trying with MergeAdapter but it can't handle swipe gesture on it's first element (ViewFlipper), it always returns ViewFlipper's item position.
Here's the picture to clarify what I'm trying to make. Top Stories is ViewFlipper and Latest Posts is ListView. And they both scroll vertically. Ignore bottom tabs and ActionBar as they are static (nonscrollable).
You've got your work cut out for you.
Here are two approaches:
1) Set the view flipper as the first row in the List view. Its a special case. Not as a header, but as a regular row.
2) Use a scroll view, and do not use the list view at all. You may have performance problems if your data for the list view is a large number of items.
Take a look at the ViewPager from the Android Compatibility Library it does what you need

Categories

Resources