I have a recycler view which has its items in a card view. The recycler view gets its data from a sql database within the app . Now I want to implement two features to this recycler view items. First , whenever the individual cards are tapped , I want them to enlarge and display more data and should shrink back when tapped again. It is not like the case of expandable list view where it expands into a child list view. I want the height of the card to increase and just show some more information and buttons. Second I want the items to swipe left . I know there is a feature for that in recycler view , but I want to customise the swipe feature. Swipe from right should be locked , and when swiped from left , It should not go off list completely. It should show two buttons and should go off list only when one of the buttons is clicked. I have been looking , but there is no proper explaination anywhere. Please guide me through this process.
For your first question, set the adapter layout_height to wrap_content and set the buttons visibility to GONE. Implement the OnClick listener in the RecyclerView adapter and set the visibility of the buttons to VISIBLE if GONE and GONE if VISIBLE or use a boolean to alternate the visibility.
For your second question, this might help:
https://www.learn2crack.com/2016/02/custom-swipe-recyclerview.html
How can I make my Android SwipeableCardViews more like the IOS 7 mail app (swipe to show buttons)
https://github.com/daimajia/AndroidSwipeLayout
Related
I have 40 ImageViews inside a GridLayout, they have different colors and I want to know if user touched the desirable image or somewhere else(for example if user touched red image). How should I do that?
Set an OnClickListener for each view and store the views. In onClick you can check the view and know what ImageView was clicked. You could also think about changing the type to ImageButtons!
If you have further problems with your Grid not being able to be clicked, check this out: http://cyrilmottier.com/2011/11/23/listview-tips-tricks-4-add-several-clickable-areas/
TLDR: Disable focusing of the views in your layout.
If you manage your images in a collection maybe think about switching to gridview and implement an adapter with an itemClickListener. So depend on which item is clicked do you action.
How GridLayout items come from the Adapter(List/Image) in Android App
I want to make the following layout in android. (Image Attached)
There is a list view and each item in the list view can has as many sub items. (One is visible in one row at a particular time), if a person wants to see further items in a particular row, then he has to use arrows provided on the left and right side of the item in the list view. (Image Attached)
On the arrow click, there should be a pager swiping type view and the next layout should come in the row.
I have tried so many approaches to do the same but have been stuck somewhere and have not been able to do the same yet:
Here I have tried all these :
1st Try
2nd Try
3rd Try
4th Try
Can anyone please tell me how to do the same functionality as shown in the figure attached and discussed above
Alright.
Try this, this should work.
Solution 1:
Have Horizontal Scroll view as child in listview, so basically you have s child now with horizontal scroll ability
Add as many as children you want to this scroll views, you can easily adjust layout of childs within scroll view to display.
Solution 2:
Have a ViewFlipper as a child withing listview
Perform the same thing as above, add as many child you want within this flipper
With flipper you get easy hastle free option like which child you want to display by default withing flipper.
Hope it help.
this pop up should bottom aligned and comes when I tap on any grid item and in the form of columns... like for 5 images first row should show 3 images and second row should show two..
I have tried with alert dialog, but it is coming in list view ...
i am trying with split action bar but it may contain only system images..
I have tried all possible things. but i am unable to get solution..
please help me...
Does any one know how to do that??????
You can set a touch listener to the grid view - setOnTouchListener.
Override method onTouch and implement your logic to show/hide the popup.
Remember a popup could also be a layout in your view for which you change the visibility from GONE to VISIBLE and viceversa. To have a better result do that with an animation (maybe fade + translate).
I am working in android application which is using listview to populate its data,In the design firstly list is shown with some of items, and on clicking on the cell it expands to show another part of the cell layout whose visiblity is "gone" on the creation of the cell.
Now if user clickes on the last cell of the listview it expands to show its invisible layout but that goes below the visible window of the screen.Now what i want to do is if on expanding the list cell its content goes below the visible window scroll listview up automatically to show complete cell.
Please suggest a best way how can i achieve it?
Try this, not sure if it will work, but give it a shot:
listView.scrollTo(0, listView.getHeight());
Let me know.
I have a list of about 100 items. In each list item I need a framelayout with 2 relative layouts. When a button called "Flip" is clicked then one relative layout will flip out and the other relative layout will flip in. And each item has full width of the screen. So, I need to show the item in a horizontal scroll view. Now, I want to keep at most 3 items every moment. When user scrolls to the first item then we have to update the 3 items. The first item will be the 2nd item. And we have to add another item at the front. In this way we have to update the items when user scrolls to the last item. I have tried many ways. I have used Gallery for the horizontal scroll view. And used the onItemSelected method. But, if I scroll the Gallery fast then it crashes. So, please someone help me to implement the 3 items idea.
It sounds like you need a ListView. Is there a reason you are trying to reinvent it?
Also don't you mean a vertical scroll view? Why are using a horizontal?