Skip to content

Instantly share code, notes, and snippets.

@Kozlov-V
Created February 24, 2015 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kozlov-V/60c3f6b0c8ce857502aa to your computer and use it in GitHub Desktop.
Save Kozlov-V/60c3f6b0c8ce857502aa to your computer and use it in GitHub Desktop.
Show AlertDialog in any position of the screen
private CharSequence[] items = {"Set as Ringtone", "Set as Alarm"};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
if(item == 0) {
} else if(item == 1) {
} else if(item == 2) {
}
}
});
AlertDialog dialog = builder.create();
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes();
wmlp.gravity = Gravity.TOP | Gravity.LEFT;
wmlp.x = 100; //x position
wmlp.y = 100; //y position
dialog.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment