Android自定义View 增添onCreate setContent等方法
来源:互联网 发布:私人摄像头直播软件 编辑:程序博客网 时间:2024/05/17 23:49
开发中经常遇到需要在一个Activity切换多个子View的情况,View用多了,自己写了些小方法,是的View和Acitivity有一些统一的特性,例如onPause等,用起来顺手点
import android.content.Context;import android.util.AttributeSet;import android.view.LayoutInflater;import android.view.View;import android.widget.RelativeLayout;import com.yayajp.dict2.service.Task;/** * @ClassName BaseUI * @PackageName com.prdoor.moviebox.ui.view * @创建人 dongrui * @修改日期 2013-10-31 下午5:46:16 * @描述 基础view,为方便定时view,增加onCreate,setContetnLayout , * doTask方法,使得view的使用方式类似activity */public class BaseView extends RelativeLayout {private LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);protected DoTaskListener doTask;public BaseView(Context context, AttributeSet attrs) {super(context, attrs);onCreate();}public BaseView(Context context) {super(context);onCreate();}public void onCreate() {}public void setContentView(int id) {LayoutInflater mLayoutInflater = LayoutInflater.from(getContext());View v = mLayoutInflater.inflate(id, null);v.setLayoutParams(params);addView(v);}public void onPause() {}public void onResume() {}public void onDestory() {}}
同时自定义Actvity,增加myAddView方法,将view添加到Activity里的同时添加到队列中,在Activity的onPause等方法里调用队列里view的同一方法,在onDestory里调用view onDestory方法后,将所有view设置为null
0 0
- Android自定义View 增添onCreate setContent等方法
- Android从零开搞系列:自定义View(1)setContent()台前幕后
- Android 自定义View需要重写ondraw()等方法
- Android在onCreate方法中获取view的宽高
- Android自定义View(一)View绘制流程以及invalidate()等相关方法分析
- Android OnCreate、setContentView方法
- Android(一)onCreate方法
- android 的onCreate 方法
- 自定义 view oncreate -> onmesure -> onlayout ->在 成员方法findviewbyid 为 null , 在 onmesure则友值
- Android自定义View的方法
- Android自定义View的方法
- android TabHost setcontent出错
- android在onCreate()方法中获取View的宽度与高度的方法实战
- android在onCreate()方法中获取View的宽度与高度的方法实战
- Android在onCreate方法中调用显示Popupwindow报错 android.view.WindowManager$BadTokenException
- onCreate方法中调用PopupWindow的错误:android.view.WindowManager$BadTo
- [Android]在onCreate方法中中获取View的宽和高
- 关于Android 尝试在onCreate方法内测量view的宽高的测试
- 第35讲
- 第36讲
- u-boot配置、编译、烧写、命令使用
- AE(C#)Shapefile导入mdb数据库
- Android SQLite数据库操作
- Android自定义View 增添onCreate setContent等方法
- freemarker报错之六
- Linux运维第7天:Linux下sed工具及shell编程
- centos下 xxx is not in the soduers file 的解决方法!
- Linux运维第8天:Linux下vim使用及find工具
- 嵌入式Linux内核制作以及TFTP下载到开发板
- JAVA 自定义注解及参数获取
- JavaWebFrame 中控制器的一些问题和测试用例
- IOS_加速计_碰撞检测_小球位置修复_dispatch_once单例