WEB开发网
开发学院手机开发Android 开发 android中如何开发用户控件 阅读

android中如何开发用户控件

 2010-05-31 14:18:00 来源:WEB开发网   
核心提示:看一下DatePicker的源码,发现如下方法:view plaincopy to clipboardprint?public DatePicker(Context context, AttributeSet attrs, int defStyle) {super(context, attrs, defStyle);L

看一下DatePicker的源码,发现如下方法:

view plaincopy to clipboardprint?

public DatePicker(Context context, AttributeSet attrs, int defStyle) {

super(context, attrs, defStyle);

LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

inflater.inflate(R.layout.date_picker, this, true);

}

public DatePicker(Context context, AttributeSet attrs, int defStyle) {

super(context, attrs, defStyle);

LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

inflater.inflate(R.layout.date_picker, this, true);

}

这样就可以用xml来设计界面,在代码中实现功能了,可以复用。

Tags:android 如何 开发

编辑录入:coldstar [复制链接] [打 印]
赞助商链接