Question

I want to display a popup like screen when I click on version icon in the menuitem . kindly explain how can I achieve this ?

Was it helpful?

Solution

I did something similar to this. I used dialog activity for that. What you have to do is use parent="@android:style/Theme.Holo.Dialog in the theme for that activity.

OTHER TIPS

Hi what you can do is you can invoke an activity normally as generally the corresponding activity declaration in the AndroidManifest.xml file looks like as follows:

<activity
android:name="com.aexample.YoursActivity"
android:label="@string/activity_name" > 
</activity>

However, there is small trick that can be done to make any activity take on a Dialog form. For example, if we change the activity declaration in the AndroidManifest.xml file to this:

 <activity
    android:name="com.aexample.YoursActivity"
android:theme="@android:style/Theme.Holo.Dialog"
android:label="@string/activity_name" >
</activity> 

What this android:theme="@android:style/Theme.Holo.Dialog" does is change the theme of an activity. It's still a complete activity, but it has taken on a dialog form.

also what you can do is you can work around AlertDialog, the following example shows you how to display an alert box in Android

AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
            context);

        // set title
        alertDialogBuilder.setTitle("Your Title");

        // set dialog message
        alertDialogBuilder
            .setMessage("Click yes to exit!")
            .setCancelable(false)
            .setPositiveButton("Yes",new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog,int id) {
                    // if this button is clicked, close
                    // current activity
                    MainActivity.this.finish();
                }
              })
            .setNegativeButton("No",new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog,int id) {
                    // if this button is clicked, just close
                    // the dialog box and do nothing
                    dialog.cancel();
                }
            });

            // create alert dialog
            AlertDialog alertDialog = alertDialogBuilder.create();

            // show it
            alertDialog.show();
/**
     * Method to get a dialog with title, message and one button
     * 
     * @param context
     * @param title
     * @param message
     * @param positiveText
     * @return AlertDialog
     */
    public static AlertDialog getAlertDialog(Context context, String title,
            String message, String positiveText) {

        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        /* builder. */

        builder.setMessage(message)
                .setTitle(title)
                .setCancelable(true)
                .setNegativeButton(positiveText,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int id) {
                                dialog.cancel();
                            }
                        });
        AlertDialog alertDialogBox = builder.create();

        return alertDialogBox;
    }

u can create custom dialog xml layout and call that xml layout in ur activity

dialog = new Dialog(activity.this);
        dialog.setContentView(R.layout.yourcustomlayout);

        dialog.getWindow().setBackgroundDrawable(
                new ColorDrawable(android.graphics.Color.TRANSPARENT));
        textview= (TextView) dialog.findViewById(R.id.textview_id);

        dialog.show();

try this

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top