本文通过实例来分析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、然后就可以对这些公共资源进行操作了


更多相关文章

  1. sharedPreferences的相关用法介绍
  2. 2015最新的 导航条《actionbar》给大家分享。
  3. Android——ImageButton按下效果设计
  4. 解决ionic在Android和iOS的一些样式上的冲突
  5. Android(安卓)EditText 密码隐藏或可见
  6. 关于com.actionbarsherlock.widget.SearchView的使用无法调用Sea
  7. Android(java)学习笔记133:ListViewProject案例02
  8. Android(安卓)activity 参数传递
  9. Android(安卓)- Activity 的 Launch mode详解 于 singleTask正解

随机推荐

  1. 用Fiddler抓取Android、Iphone网络数据包
  2. android工程建立到最后一步提示unsupport
  3. 【Android】读取sdcard上的图片
  4. android 工程运行时Unable to instantiat
  5. android 通过setContentView切换Activity
  6. Android:使用selector 在 button上无效的
  7. Android动画效果-更新中
  8. android 程序启动界面的短暂黑屏解决办法
  9. Android AIDL 双向调用的使用及相关原理
  10. Android 事件分发详解及示例代码