Android API——自定义组件(Custom Components)
来源:互联网 发布:java date 减一个月 编辑:程序博客网 时间:2024/05/21 07:03
Android 提供了一组灵活和强大的组件模型来构建自己需要的UI。主要是通过继承 View 和ViewGroup。
Android提供的常用控件,其实也是继承了View 和 ViewGroup,
View的例子:
A partial list of available widgets includes Button
, TextView
, EditText
,ListView
, CheckBox
, RadioButton
, Gallery
, Spinner
, and the more special-purpose AutoCompleteTextView
, ImageSwitcher
, andTextSwitcher
.
ViewGroup的例子:
Among the layouts available are LinearLayout
, FrameLayout
, RelativeLayout
, and others. For more examples, see Common Layout Objects.
如果很不幸,这些Android为你预先准备的widgets或layouts不能满足你的需求,那么,就自己动手,丰衣足食。
如果对于现有的widgets或layouts,你只需要修改一小部分就满足需求,那么你只需要继承它,然后重写相应的方法即可;
如果需要大概,那么直接继承View或ViewGroup本身,然后重写一切。
基本方法
1、继承View
2、重写相关方法
3、使用你的View
- Extend an existing
View
class or subclass with your own class. - Override some of the methods from the superclass. The superclass methods to override start with '
on
', for example,onDraw()
,onMeasure()
, andonKeyDown()
. This is similar to theon...
events inActivity
orListActivity
that you override for lifecycle and other functionality hooks. - Use your new extension class. Once completed, your new extension class can be used in place of the view upon which it was based.
- Android API——自定义组件(Custom Components)
- Custom Components(自定义组件)
- Android API Guides---Custom Components
- Building Custom Components/建立自定义组件
- 创建自定义组件Building Custom Components
- Building Custom Components/建立自定义组件
- Custom Components「自定义组件」翻译
- Android 用户界面---定制组件(Custom Components)(一)
- Android 用户界面---定制组件(Custom Components)(二)
- Android学习笔记————初识控件自定义(Custom Components)
- Android - Custom Components
- AndroidAnnotations——Enhance custom views 优化自定义组件
- AndroidAnnotations——Enhance custom views 优化自定义组件
- android自定义View_1——Custom Drawing
- Custom Components
- Custom Components
- Custom Components
- vue自定义公共组件components
- nginx事件模块之IO多路复用的选择
- Highcharts.js轻松做图表
- 记录一下八款开源 Android 游戏引擎
- ACM之常见的(C++版)问题解析
- 实现二------------实现Runnbale接口
- Android API——自定义组件(Custom Components)
- js中数组Array的一些常用方法。
- 配置JAVA的环境变量
- OSGI and C++
- 有关int,float,double型与字符串char*类型的相互转换
- document.write()及其样式、位置控制
- jquery的extend和fn.extend的使用说明
- 圆形头像图标简单实现
- 大话设计模式之抽象工厂模式