Get position of WearableListView - android

I need your help!
I have three WearableListViews side by side, filled with the values from 0-9.
The idea is that you can scroll the three different lists to create fast and simple a number between 000 and 999.
Now I need the selected values, but no method I tried get me the right values.
There were:
getScrollX(),
getScrollY(),
getScrollState(),
...
If you perform a click on an item within the list, you can get the position with viewHolder.getPosition(); in the onClick-method.
Does anybody know, how to get the current position scrolled to of all three WearableListView simultaneously?

Look at the answer in How can I change a Preference when WearableListView snaps to new list item?
basically add a WearableListView.OnScrollListener to your WearableListViews and implement
onCentralPositionChanged(int centralPosition);
this will do the trick.

Related

Dynamically adding items to top of listview

Is it possible to insert a ListView item to the top of the list, with the position of the most recent item going at the top? I am aware of other methods of achieving this, such as items.add(0, item);, getItem(getCount() - position - 1); as well as using listView.smoothScrollToPosition(0); within a runnble(), but the results are as shows in this image, where the numbers represent an int position index. New items added to the list are placed at the bottom, pushing all previous items upward.
I would like a result like this?
Thanks in advance.
I solved my own problem! Basically I used the method which involves placing each item in the list at index 0, items.add(0, layer); which visually, does indeed stacks the elements in my list, but at the cost of reversing the position index. All I needed to do was modify the recieved int position index so that it corresponds to the positions of the reversed list.
You can't normally do this with listview. Try bottom sheet which is explained here.

Recyclerview with X items and View more button

I would like to know if there is any way how to implement RecyclerView with only part of the collection. For example, the ArrayList would have 10 bitmaps in it, but only 6 can fit the screen without scrolling. So I want to show only 5 of them, and the 6th would be a clickable Button/ImageView which would say 'View 5 more'.
Is it possible to achieve this? Thanks.
one way would be having 2 lists in your adapter, one is the list that you actually show (show list) and the other one the full dataset. as long as you're not showing the full dataset, add a row at the end with the button show more, when clicking the button add a new batch of items from the full dataset to the show list.

Inner List in Android

I have a problem with lists.
I want to implement a scrollable big list, each element of which contains a text on the left side and a NON-scrollable inner list on the right side. (for example: the name of the flat and the list of its inhabitants names)
Both lists should be filled from the cursors and contain an informatio about them: I want to have an oppurtunitz to get all cursos fields when I click an element of the inner list.
As far as I understood I's not possible to solve it with two ListViews. ExpandableListView does not pass me because I do not want to expand the first list, I want to have the inner list always visible.
Do you have any ideas how can I realize it?
Try using a ListView for your big list, and an empty LinearLayout in each item. You fill the LinearLayout of each item programmatically in the big list adapters getView(..) method, where int position is the item number.
See also: android nested listview
Edit: Or use an ExpandableListView, which items you expand programmatically without animation with expandGroup(int position, boolean animate). Prevent collapsing by setting an ExpandableListView.OnGroupCollapseListener, in which you expand the group again. (seems a bit hacky)
Dokumentation: https://developer.android.com/reference/android/widget/ExpandableListView.html

Is there any way to display items on listview (Android) in another way?

Let's say I've got some data and they load one by one, is there any way to make every item that is added to the list view by the adapter come from the bottom of screen and then go to their original positions?
Just use :
list.setStackFromBottom(true);
It will make all the items to be added from the bottom of the list.
Do you want only to change ordering? Then you should change your getView() methon in adapter, to use mirrored position in your data.
so, you should use like this
Type object = data.get(data.size() - position);

Android: How do I remove an item from a gridview, having the remaing items shuffle into place

BACKGROUND:
I have a grid of 36 buttons, lets say a 6 rows & 6 columns numbered 1 to 36, displayed 2 rows at a time via a GridView and custom Adapter
The grid displays fine, and all of the scrolling works properly.
QUESTION:
I want to be able to click on an item, have it removed from the grid and the remain items shuffle up into place. Currently I am able to disable the item disabled, set its visibility to INVISIBLE or GONE, but none of these will actually remove it from the display.
Suggestions?
Specifically, you need to remove the corresponding object from the data set of the underlying adapter and then call adapter.notifyDataSetChanged(). This isn't going to provide you with an animation, though, if that was part of this question.
It may be interesting to try a tween animation for the item in question and then finally remove it from your adapter at the end. I'm not well-versed in animation, so I'm not sure how well this will work in an AdapterView.
You should be able to update the adapter, and then call notifyDataSetChanged to force the grid view to be updated.

Categories

Resources