android context的别
来源:互联网 发布:淘宝全球购举报 编辑:程序博客网 时间:2024/05/02 10:48
if (isChecked) { if (temp != -1) { RadioButton tempButton = (RadioButton) ((Activity)context_).findViewById(temp); if (tempButton != null) { tempButton.setChecked(false); } } temp = buttonView.getId(); }
这是在一个继承baseAdapter的自定义适配器类(不是acitvity中的内部类)里的getView方法中,
其它上面的这代码的context_必须为那个activity类的this,或是activity类名.this,通过构造方法传入这个适配器类中,不能是baseContext(),或是getApplicationContext(),如果是后两者就会报classCaseException异常,也就是说会类型转换错误!
public View getView( int arg0, View arg1, ViewGroup arg2) {if(Flag){if(arg1==null){LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
而这代码中的context,必须是那个activity中getApplicattonContext(),不能是getBaseContext(),或是Activty的context,如果是两者,程序就会报NullException异常,
注:我的那个activity界面是通过一个inflater引导进来了,
- android context的别
- 关于android的 context
- Android的Context简介
- Android Context的意义
- android context的作用
- android的context
- android的context
- Android的context浅析
- Android的context
- android的context
- android的Context理解
- android 里面的Context
- Android里的Context
- android的Context
- Android Context 的理解
- Android的Context
- android Context的使用
- Android Context的区别
- oracle exp命令
- 我第一份工作
- 更改.swp文件和.rb文件的路径
- netbeans下解决Illegal instruction的方法
- Kconfig的作用
- android context的别
- java 中异常
- SQL删除id号不同,其他都相同的学生冗余信息
- 使用mciSendCommand循环播放音乐
- 如何运行jasperReport自带的例子程序
- DEDECMS系统模版文件说明
- 谜题1.3 逻辑操作符和增量操作符
- 希尔排序(Shell Sort)
- 网络名字解释