Popuwindowhealthrecord, this is dialog.
PopuWindowHealthRecord.this.dismiss ();
Popuwindowhealthrecord extends Dialog
Dialog setting custom styles (styles)
Public Popuwindowhealthrecord (Context context) {
Super (context, r.style.healthdialog);
Set up layouts (perfect for various layouts) dialog and activity are pretty much the same.
Setcontentview (r.layout. Popuwindow_health_record);
This. = Layoutinflater. From(context);
Dialog custom style values under the Stytle. Write in XML
<style name= "Healthdialog" parent= "Android:style/theme.dialog" >
<item name= "Android:windownotitle" >true</item>
<item name= "Android:windowbackground" > @android:color/background_light</item>
<item name= "Android:colorbackgroundcachehint" > @null </item>
<item name= "Android:windowistranslucent" >true</item>
</style>
Create dialog (instantiate)
My health file.
Tvhealthrecord.setonclicklistener (New View.onclicklistener () {
@Override
public void OnClick (view view) {
Toast.maketext (Contentview.getcontext (), "Test Click", Toast.length_long). Show ();
Create Pop window
Popuwindowhealthrecord Popuwindowhealthrecord = new Popuwindowhealthrecord (context);
Parm for setting layout properties
Windowmanager.layoutparams parm = new Windowmanager.layoutparams ();
Get screen density
Displaymetrics dm = new Displaymetrics ();
DM = Context.getresources (). Getdisplaymetrics ();
Set screen width height
Parm.width =DM.WIDTHPIXELS/2;
Parm.height = Dm.heightpixels;
Setting the dialog location
This setting is close to the left
parm.x =-parm.width;
PARM.Y = 0;
Popuwindowhealthrecord.getwindow (). SetAttributes (Parm);
Set whether to click anywhere outside the dialog, dialog disappears
Popuwindowhealthrecord.setcanceledontouchoutside (FALSE);
Popuwindowhealthrecord.show ();
Android custom Dialog Beginner level explanation