I am implementing an app which has a gridview of images in one activity and one fragment for each image which contains the image in full screen. When i click on any of the images in the grid, it should open up the corresponding fragment. However, we cannot use intent to do this. here is my code
public void onItemClick(AdapterView<?> arg0, View arg1, int position,
long arg3) {
// TODO Auto-generated method stub
if(position==0)
{
Intent i=new Intent(Gallery.this,ImageFrag1.class);
startActivity(i);
}
and the fragment is
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class ImageFrag1 extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.imagefrag1, container, false);
}
}
This fragment is bound to an activity ImagesSwipe. SO how do i achieve the transition between grid view item and its corresponding fragment. Thanks
GridView
load in aFragment
? – SlaytonAndroid using intent to open a fragment from an activity
However, we cannot use intent to do this. here is my code
. What exactly do you want to achieve? – Gabbey