-1

I need to create a View programmatically that displays some information I have. The View should popup from the Current Activity. Like this:

enter image description here

Is there any library or example? Because in Android I really have no idea on how to start

LS_
  • 6,763
  • 9
  • 52
  • 88

2 Answers2

2

You can use an Dialog to achieve your View Requirement. You can create an AlertDialog problematically and add view elemets in to it.

EDIT

Reference code :

public static void wrappedImageDialog(final Context context) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setPositiveButton("Get Pro", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
            }
        }).setNegativeButton("No thanks", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
            }
        });

        final AlertDialog dialog = builder.create();
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View dialogLayout = inflater.inflate(R.layout.go_pro_dialog_layout, null);
        dialog.setView(dialogLayout);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.show();
    }
Sanjeet A
  • 5,171
  • 3
  • 23
  • 40
  • ok that is what I was thinking too, but since I'm supporting android api 9+ do you know if it is possible to customize the Dialog elements? – LS_ Jul 23 '15 at 10:05
  • Yes as per my implementation you can customize on API level 9. – Sanjeet A Jul 23 '15 at 10:08
0

If you want to start an Activity like a popup, you need to create an Activity and set this:

android:theme="@android:style/Theme.Dialog"

in the manifest.

Manfredi
  • 172
  • 1
  • 12