Animate Same Activity - android

Is it possible to animate the same activity without actually reloading the activity instance?
I would like to make my ListActivity slide aside and reveal itself again but with new data in the ListView. This will occur each time the user drills down the list.

Using ViewAnimator should solve your problem.

Related

Reusing the MainActivity in Android

I have a MainActivity in my Android Application where I am showing a list of items in a RecyclerView.
Each Item can have multiple sub items, and sub items can have its own child items too (like a tree).
I want to show the same activity for main and sub items, but with an Back Arrow on ActionBar.
Is it possible to reuse MainActivity?
yes, you can do this using fragments. Instead of showing lists in MainActivity take a fragment container in MainActivity and create fragments where you can show your lists and subitems according to your requirement.
By checking fragment instance in MainActivity, you can show and hide backarrow of actionbar.
Check this
Yes, it is possible to reuse MainActivity. Each time you call startActivity without special launchMode or flags, a new instance of MainActivity will be created and it is considered an absolutely new one.
I have encountered a similar problem while working on a File Manager application. So What I did is created a FolderNavigator stack that helped me in keeping the track of users current position using which I showed breadcrumbs at the top. And I hooked my fragment with this navigator so as soon as the peek of stack changes my folder gets notified and it will load the data of the peek of the stack. When I press back I will just pop the stack and as my fragment is already hooked with the peek of stack it will show the respective data.
You can use fragments to fulfill your requirements.
From this SO answer:
Fragments are more of a UI benefit in my opinion. It's convenient for the user sometimes to see two different views of two different classes on the same screen.
For more about fragments, read this document.

Slide in and out only a portion of an Activity without using fragments

Is it possible to create an activity slide in and slide out transition without animating the whole activity? Similar to fragment transition but with activities.
I know this could easily be done with fragments but I would like to avoid handling multiple fragments in a single activity to avoid creating a God Activity.
What are your thoughts on this?
As we have discussed in the comments, using Child Fragments could be an idea to solve the issue.

How to pass slowly an animation pushing a button

I use a View Pager in my app to get animations between fragments, but I've got a problem because I use a button to pass fragments, I have disabled swipe option, and when a fragment pass to other, it is really quickly and you can not see anything. I want to pass more slowly so, Can you help me please?
I use this method to pass fragments:
myViewPager.setCurrentItem(int fragment_position);
If you need more information just say it.

How to slide between a CameraActivity and a ListView Activity?

I have an activity that displays a camera screen, another one that displays a dynamic list of things, and I would like to slide between them.
The problem is that the ViewPager only allows me to slide between different layouts, without any activity-related effect.
Thanks for your help!
I think that using a ViewPager is what would be the easiest way. But if you don't want to, maybe you can try something like that :
Code something to detect the swipe gesture.
When the swipe gesture is detected, start the second activity whith a slide transition.
I've never done something like that. It's just a though.

Creating/Rendering Activity before starting it

We use different activities to navigate through our app. One of them is very complex and contains a lot of nested views/images etc, so when I usestartActivity(intent1) in the activity before it, there is a short delay and it feels/looks laggy.
All the information needed to create the content views is known in advance.
So my question is: is there a smart way to prerender/preload the activity or its content view?
As i figured the intend only holds information about the next activity but no instance of the activity itself, so i assume there is no way to tell the intend to create the activity before i call the startMethod.
One idea i hat was to create a static view before starting the activity and set this view as contentView in the onCreate() method. But it seems like a bad hack to me.
Thanks in advance!
The best solution would be not to start a completely new activity but using a ViewPager or ViewFlipper. Switching between Views should be then nearly instantaneous and you also get the chance to easily apply animations.
If that is not possible you could start a new activity but put a ViewSwitcher in there. The first View would be a progress bar. The second view is inflated and added to the Switcher in a background thread.

Categories

Resources