大佬教程收集整理的这篇文章主要介绍了android – LayoutInflater有时(随机)膨胀错误的背景颜色,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
细节:
我有一个带有cursorAdapter的ListView.我使用以下@L_197_7@使用一个静态项目(所以我认为这不是回收问题)来扩充列表项目:
@Override public View newView(Context context,cursor cursor,ViewGroup parent) { LayoutInflater vi = (LayoutInflater) context.getSystemservice(Context.LAYOUT_INFLATER_serviCE) ; View v = vi.inflate(R.layout.bookmark_item,null) ; //bindView(v,context,cursor) ; Log.wtf("newView","View color: " + Integer.toString(((ColorDrawablE) (((RelativeLayout)v.findViewById(R.id.bookmark_row)).getBACkground())).getColor())) ; return v; }
我的布局/ bookmark_item.xml:
<RelativeLayout xmlns:android="http://scheR_43_11845@as.android.com/apk/res/android" xmlns:tools="http://scheR_43_11845@as.android.com/tools" android:layout_width="fill_parent" android:layout_height="wrap_content" > <RelativeLayout android:id="@+id/bookmark_row" android:layout_width="match_parent" android:layout_height="wrap_content" android:BACkground="@color/app_menu_item_BACkground" tools:ignore="USELEssParent" > <TextView android:id="@+id/bookmark_item_title" android:layout_width="match_parent" android:layout_height="wrap_content" /> </RelativeLayout> </RelativeLayout>
内部RelativeLayout的背景颜色设置为@ color / app_menu_item_BACkground.这个颜色在我的R.java中:
public static final int app_menu_item_BACkground=0x7f0a0036;
我还有一个名为@ color / app_menu_item_colored_BACkground的颜色,我在@L_197_7@中的其他地方使用的颜色,它与我的书签列表和适配器没有任何共同之处.它在R.java中也有不同的资源ID:
public static final int app_menu_item_colored_BACkground=0x7f0a0038;
它们都是不同的颜色:
<color name="app_menu_item_BACkground">#517409</color> <color name="app_menu_item_colored_BACkground">#f6efde</color>
然后,在运行我的应用程序时,有时(并非总是),我的View使用了错误的app_menu_item_colored_BACkground背景颜色.我记录了膨胀的视图颜色(参见上面的@L_197_7@),它甚至有时不同:
"newView" - "View color: -11439095" "newView" - "View color: -593954"
注意,第一种颜色是#517409,第二种颜色是#f6efde.
奇怪的是,我只能在一台设备上重现错误,三星Galaxy S3 mini,每10次尝试大约2-3次.
以上是大佬教程为你收集整理的android – LayoutInflater有时(随机)膨胀错误的背景颜色全部内容,希望文章能够帮你解决android – LayoutInflater有时(随机)膨胀错误的背景颜色所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。