Android——公共XML资源的使用
16lz
2021-01-24
本文通过实例来分析Android中公共的XML数据的使用。
1、例如公共的XML文件如下,即公共的图片、按钮,common.xml
<span style="font-size:10px;"><ImageButton android:id="@+id/chat_keyboard" android:background="@drawable/hichat_btn_common_selector" android:src="@drawable/hichat_btn_keyboard" /> <Button android:id="@+id/chat_audio" android:text="@string/chat_audio_start" /> <ImageButton android:id="@+id/chat_share" android:background="@drawable/hichat_btn_common_selector" android:src="@drawable/hichat_btn_share" /></span>
2、然后通过Java代码来使用这些公共资源
<span style="font-size:10px;"> private View convertView; private ImageButton actionKeyboard; private Button actionAudio; private ImageButton actionShare; convertView = <span style="color:#CC0000;">LayoutInflater.from(context).inflate(R.layout.hichat_bottom_action_audio, this, true)</span>; actionKeyboard = (ImageButton) convertView.findViewById(R.id.chat_keyboard); actionAudio = (Button) convertView.findViewById(R.id.chat_audio); actionShare = (ImageButton) convertView.findViewById(R.id.chat_share);</span>
3、然后就可以对这些公共资源进行操作了
更多相关文章
- sharedPreferences的相关用法介绍
- 2015最新的 导航条《actionbar》给大家分享。
- Android——ImageButton按下效果设计
- 解决ionic在Android和iOS的一些样式上的冲突
- Android(安卓)EditText 密码隐藏或可见
- 关于com.actionbarsherlock.widget.SearchView的使用无法调用Sea
- Android(java)学习笔记133:ListViewProject案例02
- Android(安卓)activity 参数传递
- Android(安卓)- Activity 的 Launch mode详解 于 singleTask正解