简体   繁体   中英

setting cache for preferences list in android

I'm trying to change the background of a preference screen in my app. I was able to add an image by doing this:

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.applicationsettings);

        findViewById(android.R.id.list).setBackgroundDrawable(getResources().getDrawable(R.drawable.app_bg));
    }

The background comes up, but when I scroll, it shows a black cache in a normal list, I set the cache hint,,,, but here I cannot do that! is there a way around it?

I have tried: "findViewById(android.R.id.list).setDrawingCacheBackgroundColor(Color.TRANSPARENT);" but it didn't work.

Update The solution is:

ListView listView = (ListView)findViewById(android.R.id.list);
listView.setBackgroundDrawable(getResources().getDrawable(R.drawable.app_bg));
listView.setCacheColorHint(Color.TRANSPARENT);

Thanks to: user370305

Try this,

ListView listView = (ListView)findViewById(android.R.id.list);
listView.setBackgroundDrawable(getResources().getDrawable(R.drawable.app_bg));
listView.setCacheColorHint(Color.TRANSPARENT);

and let me know what happen..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM