Coder Social home page Coder Social logo

quickdialog's Introduction

QuickDialog

QuickDialog可以很好的统一管理和构建dialo,具有很好的扩展性。
1.使用DialogUtils来管理构建Dialog的主题样式以及位置等。
2.使用DialogCreater来实例化dialog。
3.DialogHolder返回该dialog对应的viewHolder.
每一个dialog的布局对应一个DialogCreater

public class NoticeDialogCreater extends DialogCreater{
  
  public NoticeDialogCreater(Activity mActivity) {
  	super(mActivity);
  	
  }
  @Override
  public void createDialog() {
  	dialogView=View.inflate(mActivity, R.layout.dialog_notice_view, null);
  	dialogHolder=new NoticeDialogHolder();
  	((NoticeDialogHolder)dialogHolder).tv_title=(TextView) dialogView.findViewById(R.id.tv_title);
  	((NoticeDialogHolder)dialogHolder).tv_detail=(TextView) dialogView.findViewById(R.id.tv_detail);
  	((NoticeDialogHolder)dialogHolder).tv_sure=(TextView) dialogView.findViewById(R.id.tv_sure);
  	dialog=DialogUtils.createDialogCenter(mActivity, dialogView, R.style.Trans_Fullscreen);
  }
  
  public	class NoticeDialogHolder extends DialogHolder{
  	public TextView tv_title;
  	public TextView tv_detail;
  	public TextView tv_sure;
  }
}

在Activity中使用

public class MainActivity extends Activity implements OnClickListener{

	NoticeDialogCreater.NoticeDialogHolder dialogHolder;
	Dialog dialog;
	NoticeDialogCreater noticeDialogCreater;
	
	TextView tv_dialog;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		//创建
		noticeDialogCreater=new NoticeDialogCreater(this);
		dialog=noticeDialogCreater.getDialog();
		dialogHolder=(NoticeDialogHolder) noticeDialogCreater.getDialogHolder();
		dialogHolder.tv_title.setText("温馨提醒");
		dialogHolder.tv_detail.setText("android(Google公司开发的操作系统)");
		dialogHolder.tv_sure.setOnClickListener(this);
		
		tv_dialog=(TextView)findViewById(R.id.tv_dialog);
		tv_dialog.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		if(v==dialogHolder.tv_sure){
			dialog.dismiss();
		}else if(v==tv_dialog){
			dialog.show();
		}
	}

}

quickdialog's People

Contributors

ranchaoqun avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.