This is primarily a design question. I've implemented SimpleOnGestureListener on an ItemizedOverlay because I wanted to catch the onLongPress event as well as the onDown and onTap events. Everything is working okay but now I need to transition to a new activity on a specific onLongPress event. In this particular case an alert dialog is insufficient for my needs. Problem is transitioning from the overlay to an activity and back to the overlay. Usually, its from one activity to another and maybe back again. In addition, the code in my overlay class is getting quite long (about 450 lines) so it needs refactored and a bit more SRP. I can't see any way to attach the SimpleOnGestureListener to the Overlay from within the activity which references it, nor the MapView. Most examples I've looked at are noddy 'make a Toast' examples.
I'm not quite sure if I getting your question right, but you can have inter-view transition, e.g. with ViewFlipper or FrameLayout with a fling detector.
You can look how the stock calculator manage its transition.
Related
Is there documentation or an API that allows for an object to be flicked in a certain direction, such as a button? I've tried using 'drag & drop' to try and emulate this feature but not with the same results.
Here is an example: http://youtu.be/J-83lssy5kA?t=1m47s
Basically, you can see the guy flick the chat-head towards the close icon to close the chat. The same features are found in android launchers where you can flick to remove an icon fromthe home screen. Are those gestures custom built or is it an API, thanks.
The flick that you are talking about is called fling officially. Yes, you can handle fling events using the Android API by having your activity implement the GestureDetector.OnGestureListener interface. This interface will let you handle all the common gestures like scroll, long press, fling and so on. In your case, the onFling() method will be called.
However, in your case you only want the fling gesture in which case you will have to subclass GestureDetector.SimpleOnGestureListener and override methods selectively.
For more, please refer the docs: http://developer.android.com/training/gestures/detector.html
Yes I noticed this.
I recently tried to find a coding for the same but never could and lost interest. But this is what I feel is the solution:-
In a quick time interval find 2 points cordinates of that flicking action( drag)
Then project a third point according to the slope of this line equation.
Keep updating the position of the view you flicked while you make it travel slowly from point2 to projected point3 via may be a slow loop or timer
For slope you have
(y1-y2)/(x1-x2)
I have bulit a TicTacToe game for Android and for starting a new game I call startActvityForResult() to let the user choose some options in the new Actvity. Then I call setResult() and finish() to get back to my gameActivity containing the SurfaceView in a LinearLayout.
But here comes the Problem: The whole SurfaceView is just a black area until I tap somewhere, then it acts as it should: the onTouchEvent() method is called and the game becomes visible.
Any ideas how I can get rid of that black screen?
I already tried setting the LinearLayout and the SurfaceView visible/invisible during onResume()/onPause. And invalidate()or postInvalidate()don't work either.
I found out it seems that it is displayed correctly, if the surface is drawn twice, so I call postInvalidate()inside of draw()via a boolean flag.
This is difficult to answer without any code or more detailed information, but you should start/stop rendering to your surface view in the onPause()/onResume(), or in the onSurfaceDestroyed()/onSurfaceCreated() methods. So basically, you must properly handle the surface view in the activity lifecycle.
This is quite specifically dealing with this topic (activity lifecycle + surface view).
As a quick fix, you could just try calling onTouchEvent() manually in onResume or onSurfaceCreated().
I have been trying to find a way to get this done but keep running into issues.
I want to be able to have a map in a frame (it does not necessarily have to be a FrameLayout, i just want it framed so it only takes up 1/2 or 2/3 the screen) ontop of my current layout and to have the current activity still displayed behind it.
In a perfect world, i would like to attach this view to a button and animation so clicking the button causes this view to slide in from offscreen left and settle in the center of my current activity, while still being fully clickable and and the map being useable (can zoom, click, etc.)
I have tried doing this with a fragment, but the issue is that the Activity i am working in is already extending another class that is absolutely necessary, so i can not extend Fragment or FragmentActivity, so i cant use fragments (unless i am missing a work around to achieve this.)
The same goes for MapActivity and MapView, cant extend the MapActivity class so cant use MapView.
Any time i try to inflate a map view or anything i get runtime errors because my activity does not extend the pertinent class. Is there a work around for this?
Does anyone have a suggestion as to how i can get this map to display the way i am looking for?
This is easily achieved in iOS but i cant seem to figure it out in Android.
Thank you in advance
EDIT
I am not looking for code, unless you have a specific example in which case obviously code is very helpful, but i am looking for an idea as to how to achieve this -- a push in the right direction if you will -- so i can write the code myself.
Solved this by adding a frame layout to my "Main" activity. That frame layout's class was set to my Map class. The Map class extended FragmentActivity and its contentView is set to my map_fragment.xml. The map_fragment.xml contains only a fragment and that fragments name is set to com.google.android.....SupportMapFragment.
After setting up my project in this way as well as setting up the correct screen layouts and dimensions for sizing purposes as well as defining a GoogleMap in my Map class, i was able to display a fully usable and interactive map over my "Main" activity.
I overrode some Activity transition animations to the Map class and got my project working 100% how i want it to.
I didnt ask for code, so i will not supply any code, but this process is pretty straight-forward if you follow the same process as i have described above.
I'm working on a viewFlipper that switch between listviews, and so far, so good. I launch animations on a onTouchEvent. My problem is that to go in the onTouchEvent, I have to tap on a area empty of component, like if my activity is the last component to ask for the focus.
I want the exact other way around. I want that wherever I tap on the screen, despite of the others components, it launches the onTouchEvent. Must be simple but so far I did worthless research.
Thanks.
I'm trying to start an activity and create the transition as a 3d flip (as many have stated exactly like on the IPhone), unfortunately I haven't found a satisfying answer yet and I am stuck.
I've implemented http://www.inter-fuser.com/2009/08/android-animations-3d-flip.html
for the whole layout so that now when pressing a certain button the layouts are flipped, but since it refers to layout that are in activities which weren't loaded, they don't fill all their items and data (an expandable list view for example).
But when i call startActivity() after the flip the activity is created which of course hides the framelayout container on the caller activity - so i can't flip back... (I've used the overridePendingTransition but imho it shouldn't matter).
I could really use your help am losing my mind...
Thanks!
Sorry you can't do this -- the window manager currently only supports 2d animations.
I also want to flip activity as 3D animation. I just found this solution http://blog.robert-heim.de/karriere/android-startactivity-rotate-3d-animation-activityswitcher/
What they does.. startActivity with no animation any apply 3D rotation on it.