I'm working on a Campus Map App. The Map Activity is on the Main Activity, however, I have a different activity for the Custom Dialog. I always get this custom dialog.

When in fact I want it to appear like this.

I have this code for this Activity
public class AdminActivity extends FragmentActivity{
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(AdminActivity.this);
builder.setTitle(R.string.layers)
.setItems(R.array.layer_options, new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which) {
// The 'which' argument contains the index position
// of the selected item
}
});
return builder.create();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
Dialog dialog=onCreateDialog(savedInstanceState);
dialog.show();
}
}
And this code is a part from the main activity where I'm going to call the dialog..
@Override
public boolean onOptionsItemSelected(MenuItem item){
AdminDialog adminDialog;
switch(item.getItemId()){
case R.id.about:
Intent aboutUs = new Intent("com.android.cmumap.ABOUT");
startActivity(aboutUs);
break;
case R.id.search:
break;
case R.id.layers:
adminDialog= new AdminDialog();
adminDialog.show(getFragmentManager(), "custom-tag-goes-here");
break;
}
return false;
}
How do I achieve calling the map activity for my AdminActivity? Thank You.
Your class should subclass
DialogFragment, notFragmentActivity. Be sure to@OverridetheonCreateDialog(...)method. You can also get rid of youronCreate(...)method as that is not needed with aDialogFragment.To display the
DialogFragment, instead of using anIntentlike you would for anActivity, do the following from your map activity. Note that I renamed your class because now it is not anActivitybut rather aDialog: