Change ListViewItems Layout with a Right Swipe. Android - android

i've now got the listview and it's touch actions and swipe actions working. But now i'm not sure how i can implement a swipe effect, like it's in the twitter app.
I've found in the internet that it's possible to animate 2 views with a viewflipper, but is it possible to animate two layouts in the same way?
Anyone out there, who knows how i can implement such a function?
The only thing i want is to switch the ListViewsItem layout with a swipe.

Simple, set both the item views in 2 separate thread and then start both of them.

Related

Implementing a Custom ViewPager

I'm trying to create a layout manager similar to ViewPager, but I'm not sure about what the best way to implement it is.
Basically I want my views to look like this:
From there I want to transition to other views when the user swipes from any of the numbered rectangles on the sides. So, say, if the user swipes from view number 3 and to the left, I would like to transition to the following view:
Ideally, I would like the transitions to be similar to how ViewPager works (i.e. I want the transition to interact with your finger so that the transition progresses back and forth when the user moves his finger from left to right).
It seems like I will need to implement my own version of ViewPager, I'm just not sure how to go about doing this. I only need to handle a small number of simple views so I can probably get away with caching all of my views for better performance.
I know how to implement the code to detect the swipes and where in the view the swipe started, but I don't know what the proper way to implement the view transitions is and how to handle the states of all the different views.
Any pointers are greatly appreciated!
Thanks in advance.

Create UI for Application

I want to create Application which looks i this way:
I will have lets say 6 Scroollable Lists (A,B,C,D,E,F). They should change by touch event.
For example we see Scrollable List B, I touch screen and move to left and next I see Scrollable List C, I touch screen and move it to right and I see Scrollable List B).
The name do Scrollable List (NameOfScrollableList shoud be change with touch event for Scrollable List)
How to do it? (I am not asking for code. I want to know a proper aproach to this problem :) )
If i understand correctly you want to horizontally scroll between your lists. Have a look at ViewPager, which is ideal for horizontal scrolling. The put a ListView inside each page of ViewPager.
That's what I'd do.
Most probably you are looking for ViewPager
This might help you

Scrolling Functionality

I need to implement a UI like this:
In the above screen row needs to be scrolled horizontally and columns need to be scrolled vertically.
I have not used Gallery as It is being deprecated. Here are some scenarios which I have tried:
1. Combination of GridView and ListView.
2. Combination of ListView and Horizontal ListView(Custom Component).
Option 1 did not work for me but I could make it with option 2.
With option 2 perfomance is not good.
Solution: I am thinking of implementing 4-5 horizontal listviews inside scrollview with Gestures so that I can handle the vertical swipe thru code or by subclassing the ScrollView and overriding the onScrollChanged method.
But I am looking for some more optimized solution.
Any help is appreciated.
Thanks
Use webview and push the content into it through JS hooks.
I have gone with my solution if anyone can suggest a better solution then obviously I will go with it:
Solution:
Implemented 4-5 horizontal listviews inside scrollview with Gestures
and handled the vertical swipe thru code or by subclassing the
ScrollView and overriding the onScrollChanged method.

PopupWindow with swiping scrollable views

I'm trying to create a Popupindow in which the views can be changed by swiping. Each view should also be scrollable when larger than the popup window. I also want to move only one view when swiping. I can't find any simple way to do that (the Gallery move several views when swiping).
Is there any widget I missed or do I have to implement everything to achieve that (with ViewFlipper and gesture detection for instance)?
Anybody can help with the best way to do that?
Thanks
I've found and ended up using the fantastic HorizontalPager.

Android: Next/Previous fling that sticks to the finger similar to Home Screen

I want to give my app a nice touch by allowing users to slide the page left or right instead of just using next/previous buttons (similar to the home screen).
What is the best way to do that? I assume I would have to override one of the Activity.on... methods and that I would also have to put my page's main View in a ViewGroup that allows me to shift pages left and right.
ViewFlipper is your friend!
Here you can see a nice video of the ViewFlipper in action and also a very good tutorial:
http://www.inter-fuser.com/2009/07/android-transistions-slide-in-and-slide.html
The solution is even easier these days with the release of Compatibility Package r3. You can download here: http://developer.android.com/sdk/compatibility-library.html
It includes
ViewPager: A ViewGroup that manages the layout for the child views, which the user can swipe between.
PagerAdapter: An adapter that populates the ViewPager with the views that represent each page.
and Fragment versions of those, if you are that way inclined.
The pager code is compatible back to API version 4 (1.6), and I just implemented a dynamically generated viewPager coming off a dynamically generated ListView in about 2 hours. I'm a novice, so this is definitely the preferred path.
There is an example app here: http://geekyouup.blogspot.com/2011/07/viewpager-example-from-paug.html
If one wants to flip between two activities perhaps one can apply this animated transition:
Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
startActivity(intent);
finish();
//transition using XML view animations
overridePendingTransition(R.anim.slideinfromright, R.anim.slideouttoleft);
Use GestureDetector to detect if the touch event is a scroll.
If the first event to the first call to onScroll is ACTION_DOWN then you should see if it was a dominantly horizontal scroll. If so then your scroll is started and you should shift the absolute position of the view that fills the page.
For non deprecated absolute positioning, see my answer here Android: Alternative to AbsoluteLayout (I really do need absolute positioning)
You will want to be cautions of whether you return true to consume the touch events or not.
GestureDetector does not have a callback for scrolling having stopped. You will have to check if there was an ACTION_UP before you call GestureDetector.onTouchEvent and if there was an action up and you did have an unfinished scroll then you should set the absolute position to the destination location and use a TranslateAnimation to make it look nice moving from current to destination.
Edit:
GestureDetector did not work well at all if the child views also wanted to respond to touch events. I ended up creating a subclass of FrameLayout (one of the most basic layouts and the closest thing to a non intrusive parent view) and overriding dispatchTouchEvent. I just took all the events and did the detection myself.
cant we use Gallery view here?? with the adapter the whole page can be inflated inside gallery view adapter getView() and it will manage the left right scrolling perfectly.

Categories

Resources