I am trying to implement a simple tree-like menu. I have a ListView as the root. Each item is a custom View that consists of an arrow icon at the right if it has a submenu and a checkbox taking up the rest of the row. This is all great.
Now here is what I want to do and can't figure out how (I am new to Android, but Googling didn't help me):
If the user slides to the left on an item with an arrow, the whole list will slide out to the left and the corresponding submenu will slide in from the right. If the user slides to the right anywhere on the menu, the whole menu will slide out to the right and the parent menu will slide back in from the left. When you picture it it is really a simple concept.
My problem seems to be double:
I can't figure out how to capture a sliding motion. I assume there is some onSlide event or some such, but I can't find it.
I can't seem to attach events to the individual items. I tried just a simple toast with the onItemClickListener and couldn't get it to fire.
Any help or reference would be appreciated.
For the Sliding, check out the ViewPager class and the matching Adapter class, but generally what you describe sounds a lot like iOS and you should rather not try to duplicate a behaviour that's alien to Android users.
Related
Good evening everyone,
I've been struggling to find out a way to do this. I have an activity. In this activity I have a "top menu", and a fragment holding a listview. The goal is for the top menu to be expanded either when the setting button is pressed, or the down arrow is swiped:
Currently, I'm just adjusting the height and properties of the top menu view according to if it's expanded or not. I'm pretty sure this is not the proper way to implement this. Thanks in advance!
I have faced similar problem with swiping elements. You can use OnTouchListener and GestureDetector to detect dragging
I wrote simple android library for this problem, it has also functions to expand view on your setting button press.
swiping library
I want to create a custom listview that scroll horizontally and stacks the last 4 items in the view instead of allowing them to go off screen. The stack should look something like this: . So if a user scrolls all the way to the left they see a regular listview, but as they scroll right, if an item was supposed to go off screen, it is instead stacked behind the last item in the list, with a max of 4 stacks. What's a good basic way to accomplish this? I already found the horizontally scrolling listview library I wanted to use but don't know where to start on the stacking part.
Currently I'm developing a small app for my parents' business. I'm trying to create a custom menu. I'd like to have something similar to this:
If you look at it, the screen is divided in two sections. The upper section is just an image and the lower section is the menu. I'd like to achieve this:
If the user places his finger over an item of the menu and swipes to the right, all the items move one position right, and the opposite if the user swipes left.
I'm quite new in this field and I'm not looking for a piece of code. I just want some tips on what to search because I don't know even where to start.
Thanks a lot!
By what I understood, ViewPager should be able to solve your problem. You hsve it nested in your layout under the main image. Have a look here: http://developer.android.com/training/animation/screen-slide.html
I've already implemented a list to display a list of songs for an app that I'm making. In the application, you can upvote songs to a communal player (or unvote them, if you placed a vote for it). Screen shot.
I was able to implement a fling gesture that you'd use to vote (swipe to the right) or unvote (swipe to the left), but you don't see any animation or selection on the song you chose. So, I was hoping to get something working where (at the least) another TextView replaces it in a sliding animation, kind of like how on contacts in Samsung's TouchWiz you can swipe right to call or left to message.
What would be the best way to go about this?
Should I try to make my ListView a list of ViewFlippers and use my fling gesture? (doesn't allow me to slide halfway and then change my mind) Or should I try to use something like this HorizontalPager: http://code.google.com/p/deezapps-widgets/ where each list item is one of those.
Is there a better option that I haven't suggested?
I have a ListActivity as my main activity. I want to be able to do a few things on a single item in the list i.e.
Longpress to bring up a contextmenu for that item
Swipe left to right to slide a new screen from the right to edit the list item.
Does anyone have any code they can show me that does this?
Longpress to bring up a contextmenu for that item
See here for how to use context menus. Here is a sample project that demonstrates their use.
Swipe left to right to slide a new screen from the right to edit the list item.
See here for how to use gesture libraries. Here is a ViewSwiper that adds gestures to a ViewFlipper. Here is an implementation of a drag-and-drop ListView, based on some poorly-understood code culled from Android itself. Blending all of that together, you may be able to implement what you seek. However, this will be rather difficult, and may not result in a user interface that is very usable. I strongly encourage you to simply have list item clicks be the way to indicate to edit an item, not a gesture.
I think You can use a 2 Child ViewFlipper as your Listitem.
one child for a normal dispaly(a TextView maybe), another a EditText.
and in case it work as you said, don't forget to set gesterListener on your ViewFlipper,do showNext or showPrevious in your OnFling method.