How to hide action bar before activity is created, and then show it again?

I need to implement splash screen in my honeycomb app. I use this code in activity’s onCreate to show splash: setContentView(R.layout.splash); getActionBar().hide(); and this code to show main UI after sometime: setContentView(R.layout.main); getActionBar().show(); But before onCreate is called and splash appears, there is small amount of time when action bar shown. How can I make … Read more

How do I add a Fragment to an Activity with a programmatically created content view

I want to add a Fragment to an Activity that implements its layout programmatically. I looked over the Fragment documentation but there aren’t many examples describing what I need. Here is the type of code I tried to write: public class DebugExampleTwo extends Activity { private ExampleTwoFragment mFragment; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); … Read more

Animate the transition between fragments

I’m trying to animate the transition between fragments. I got the answer from the following Android Fragments and animation FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_right); DetailsFragment newFragment = DetailsFragment.newInstance(); ft.replace(R.id.details_fragment_container, newFragment, “detailFragment”); // Start the animated transition. ft.commit(); And my R.anim.slide_in_left <?xml version=”1.0″ encoding=”utf-8″?> <set xmlns:android=”http://schemas.android.com/apk/res/android”> <translate android:fromXDelta=”50%p” android:toXDelta=”0″ android:duration=”@android:integer/config_mediumAnimTime”/> <alpha android:fromAlpha=”0.0″ android:toAlpha=”1.0″ android:duration=”@android:integer/config_mediumAnimTime” /> … Read more

Why fragments, and when to use fragments instead of activities?

In Android API 11+, Google has released a new class called Fragment. In the videos, Google suggests that whenever possible (link1, link2), we should use fragments instead of activities, but they didn’t explain exactly why. What’s the purpose of fragments and some possible uses of them (other than some UI examples that can be easily … Read more