虽然Android 系统提供了大量的组件, 但也可以通过定制组件的方式来实现更复杂、更特殊的功能,
可以通过如下 3 种方式来定制组件
1 继承原有的组件 2 组合原有的组件 3 完全重写组件
先看一个示例: 继承原有的组件————带图像的TextView
实现定制组件的一个重要环节就是读取配置文件中相应标签的属性值
先看布局文件main.xml :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mobile="http://net.blogjava.mobile" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<net.blogjava.mobile.widget.IconTextView
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="第一个笑脸