自定义Android Dialog

	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,,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。