if (audioFileList.get(position).isLastItem()) {
convertView = inflater.inflate(R.layout.fragment_sound_add_button, null);
return convertView;
我如何捕捉:
if(convertView== R.layout.fragment_sound_add_button) {
remove layout, inflate new layout
}
尝试一下
在布局文件“ Fragment_sound_add_button”内部,向根添加一个ID。
//Root of fragment_sound_add_button
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root_fragment_sound_add_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
然后在代码内检查您的convertView是否包含此ID
if (audioFileList.get(position).isLastItem()) {
if(convertView.findViewById(R.id.root_fragmentn_sound_add_button) != null){
//inflate the layout again
convertView = inflater.inflate(R.layout.fragment_sound_add_button, null);
} else {
//convertView doesnt contain R.layout.fragmnt_sound_add_button
}
return convertView;
}
我希望这会有所帮助!