You can check DialogFrament, here is an example .
Instead of using intentions, you use the FramentManager:
if(position==0) { FragmentManager fm = getFragmentManager(); ImageFrag1 imageDialog = new ImageFrag1() ImageFrag1.show(fm, "image_title"); }
And your dialog box becomes:
import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class ImageFrag1 extends DialogFragment { public ImageFrag1() { } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.dialog_fragment, container, false); } }
source share