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