Show dialog in a layout on Android

My ui have 2 LinearLayout, layout1 and layout2. And use below code to show dialog:

private AlertDialog MyDialog;
public void adddialog() {
    AlertDialog.Builder MyBuilder = new AlertDialog.Builder(this);
    MyBuilder.setTitle("Title")
    MyBuilder .setView(ListView);
    MyDialog = MyBuilder.create();
}

I want to set the dialog position on the top-right of layout2. How can I arrive it?

Answers


private AlertDialog MyDialog;
public void adddialog()
{
  AlertDialog.Builder MyBuilder = new AlertDialog.Builder(this);
  MyBuilder.setTitle("Title")
  MyBuilder .setView(ListView);
  MyDialog = MyBuilder.create();
  dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
  WindowManager.LayoutParams dialogParam = MyDialog.getWindow().getAttributes();

 dialogParam.gravity = Gravity.TOP | Gravity.RIGHT;
// dialogParam.x = 100;   //x position
// dialogParam.y = 100;   //y position

 MyDialog.show();
}

Need Your Help

Trying to understand adding to arrays in C when coming from C#

c arrays dynamic-arrays

I'm in a situation where I need to make a byte array buffer that I can update throughout the life a of program. If I have two C arrays

Get properties of qStylesheet

c++ qt

For my aplication I use qStylesheet. In a custom widget I draw some things overriding the paintevent method. I want to use the colors of this widget, set by the qStylesheet to achieve consistency, ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.