android 弹出一个广告

转载:QGlaunch


布局文件代码如下:




    

        

        

关键代码如下:

Context context = MainActivity.this;
		dia = new Dialog(context, R.style.edit_AlertDialog_style);
		dia.setContentView(R.layout.activity_start_dialog);

		Button mClose_btn = (Button) dia.findViewById(R.id.btn_close);
		mClose_btn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				dia.cancel();// 关闭弹出框
			}
		});
		dia.show();

		dia.setCanceledOnTouchOutside(false); // Sets whether this dialog is
												// canceled when touched outside
												// the window's bounds.
		Window w = dia.getWindow();
		WindowManager.LayoutParams lp = w.getAttributes();
		lp.x = 0;
		lp.y = 40;
		dia.onWindowAttributesChanged(lp);


你可能感兴趣的:(移动开发)