在xml文件中引用内部类笔记
发布时间:2020-12-16 09:23:39 所属栏目:百科 来源:网络整理
导读:场景:自己在activity中使用内部类MyAutoCompleteTextView继承了AutoCompleteTextView重写其中一个方法,这个类只在这个activity的布局文件中使用,没有必要单独写一个类出来,现在想要在xml文件中使用这个view 参考文章:http://titanseason.iteye.com/blog
场景:自己在activity中使用内部类MyAutoCompleteTextView继承了AutoCompleteTextView重写其中一个方法,这个类只在这个activity的布局文件中使用,没有必要单独写一个类出来,现在想要在xml文件中使用这个view 参考文章:http://titanseason.iteye.com/blog/1831185 使用上面文章里面的方法可以在xml中引用,但是在findViewById找到以后不能强转为AutoCompleteTextView,报错。 解决方法:将View修改为AutoCompleteTextView。 布局文件如下: <AutoCompleteTextView class="com.smb.merchant.activity.LoginActivity$MyAutoCompleteTextView" android:id="@+id/et_login_name" style="@style/tm_text_large" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginLeft="@dimen/tm_layout_margin_defalut" android:layout_weight="1.0" android:background="@null" android:hint="@string/tm_str_account_name_hint" android:imeOptions="actionNext" android:textColorHint="@color/text_color_login_hint" android:dropDownAnchor="@id/layout_username" />另:开始我在写class里面的包名的时候是class="com.smb.merchant.activity$MyAutoCompleteTextView",没有写全,少了.LoginActivity这个类名,可是我运行起来没有问题,不知道为什么,好神奇。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ruby-on-rails – 通过http标头传递真实性令牌
- JSONObject j=JSONObject.fromObject(map) 这部分后就没反应
- flash – Adob??e Animate Snap SVG插件 – 巨大的文件
- c# – 为什么我必须为SQL查询转换返回参数值?
- PostgreSQL笔记
- c# – 从DotPeek(或等价物)重新创建解决方案/项目?
- quick - cocos2d 本地数据存储
- cvc-complex-type.2.4.a: Invalid content was found start
- swift语言的学习笔记八(保留了许多OC的实现)
- PowerShell 操作 xml