Tuesday, April 9, 2013

[android help] How to show second fragment from first fragment with in a single activity


I am developing a simple android app only for tablets and using android 4.0. My application have the main screen like as follow:


enter image description here


Oncreate() of Main Activity I am adding Fragment A in the main.xml using following code:



FragmentTransaction ft = getFragmentManager().beginTransaction();
Fragment imageFragment = new ImageFragment();
ft.replace(R.id.fragment_container, imageFragment);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ft.addToBackStack(null);
ft.commit();


This fragment A just have only a Image view which is clickable. Now I want that when user click on Image view then another fragment (Fragment B) should call and it replace the image view. The Fragment B have a VideoView which play the video.


So My second screen should be like as follow:


enter image description here


My problem is I am not gettting "How to call second fragment from the first one with in main screen activity?"


I can use different activities but I do not want to do so and just want to run this using fragments.


Please guide me.



.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...