码迷,mamicode.com
首页 > 移动开发 > 详细

自己定义Android Dialog

时间:2018-02-17 11:06:16      阅读:292      评论:0      收藏:0      [点我收藏+]

标签:and   text   dismiss   dia   white   version   his   textview   1.0   

	private void showDialog() 
	{
		mDialog = new Dialog(this);
		mDialog.setCanceledOnTouchOutside(true);
		
		Window dialogWindow = mDialog.getWindow();
		dialogWindow.setBackgroundDrawable(new ColorDrawable(0));
		dialogWindow.setContentView(R.layout.set_public_client_dialog);

		mDialog.show();
		
		Button cancelbtn = (Button) dialogWindow.findViewById(R.id.cancelbtn);
		cancelbtn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				mDialog.dismiss();
			}
		});
		
		Button confirmbtn = (Button) dialogWindow.findViewById(R.id.confirmbtn);
		confirmbtn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				mDialog.dismiss();
			}
		});
		
	}


<?xml version="1.0" encoding="utf-8"?

> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="306dp" android:layout_height="262dp" android:layout_gravity="center" android:background="@drawable/followupdialog_306_202" > <FrameLayout android:layout_width="140dp" android:layout_height="32dp" android:layout_marginLeft="-4dp" android:layout_marginTop="7dp" android:background="@drawable/redrobin_89_32" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="top" android:layout_marginLeft="13dp" android:layout_marginTop="4dp" android:text="@string/set_public_reason" android:textColor="@color/white" android:textSize="15sp" /> </FrameLayout> <EditText android:id="@+id/et_additional_reason" android:layout_width="257dp" android:layout_height="33dp" android:layout_above="@+id/bottom_btns" android:layout_centerHorizontal="true" android:layout_marginBottom="3dp" android:background="@drawable/redline_257_33" android:hint="@string/et_additional_reason_hint" android:paddingLeft="5dp" android:singleLine="true" android:textSize="14sp" /> <LinearLayout android:id="@+id/bottom_btns" android:layout_width="299dp" android:layout_height="44dp" android:layout_alignParentBottom="true" android:layout_marginBottom="6dp" android:layout_marginLeft="7dp" android:layout_marginRight="1dp" android:orientation="horizontal" > <Button android:id="@+id/cancelbtn" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:background="@drawable/followupdialogbtn" android:text="@string/cancel" android:textColor="@color/black" /> <ImageView android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="0.01" android:background="@color/linecolor" /> <Button android:id="@+id/confirmbtn" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:background="@drawable/followupdialogbtn" android:text="@string/confirm" android:textColor="@color/black" /> </LinearLayout> <ImageView android:layout_width="299dp" android:layout_height="0.5dp" android:layout_above="@id/bottom_btns" android:layout_marginLeft="7dp" android:background="@color/linecolor" /> </RelativeLayout>



自己定义Android Dialog

标签:and   text   dismiss   dia   white   version   his   textview   1.0   

原文地址:https://www.cnblogs.com/llguanli/p/8451447.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!