First look at the effect, I feel better than spinner effect, record the implementation process.
Final string[] Levelarray = Getresources (). Getstringarray (R.array.contact_level); Re_layout_spinner.setonclicklistener (New Onclicklistener () {@Override public void OnClick (View v) {//TODO Au
to-generated method Stub if (!isexpand) {Dialog = New dialog (mself);
Dialog.requestwindowfeature (Window.feature_no_title);
ListView Mlistview = new ListView (mself);
Mlistview.setcachecolorhint (color.transparent);
Mlistview.setadapter (New Leveladapter ());
Mlistview.setbackgroundresource (R.DRAWABLE.INFORMATION_BLUE_BG); Mlistview.setonitemclicklistener (New Onitemclicklistener () {@Override public void Onitemclick (adapterview< ;? > Parent, view view, int position, long ID) {//TODO auto-generated Method stub Tv_level.settext (levelar
Ray[position]);
if (dialog! = null) {Dialog.dismiss ();
dialog = null;
Isexpand = false;
}
}
});
Dialog.setcontentview (Mlistview); Dialog.setondismisslistener (New Dialoginterface.ondismisslistener () {@Override public void Ondismiss (Dialo
Ginterface dialog) {//TODO auto-generated method Stub isexpand = false;
}
});
Window Dialogwindow = Dialog.getwindow ();
Dialogwindow.setbackgrounddrawable (New colordrawable (Android.graphics.Color.RED)); Dialogwindow.setgravity (Gravity.left |
Gravity.top);
Windowmanager.layoutparams LP = Dialogwindow.getattributes ();
Lp.dimamount = 0f;
int[] location = new INT[2];
Re_layout_spinner.getlocationonscreen (location);
Rect out = new rect ();
Re_layout_spinner.getwindowvisibledisplayframe (out);
lp.x = location[0];
LP.Y = location[1]-out.top + re_layout_spinner.getheight ();
Lp.width = Re_layout_spinner.getwidth ();
Lp.height = layoutparams.wrap_content;
Dialogwindow.setattributes (LP);
Dialog.show ();
Isexpand = true; } else {if (dialog! = null) {DIALOG.DIsmiss ();
dialog = null; }
}
}
});
New Leveladapter () put a textview, the other needs to say is the dialog pop-up location settings, I want to let it stick to my relativelayout appear to get this relativelayout position, and re_ Layout_spinner.getlocationonscreen (location), get the position from the top of the screen, so also get the height of the status bar, minus this height can be correctly displayed in the position we need.