I have a ListView with a custom CursorAdapter. Between the parameter of CursorAdapter I have the theme, CursorAdapter set colors from passed theme.
private MyCustomAdapter mAdapter;
public void onCreate(Bundle savedInstanceState) {
ListView lv = (ListView)findViewById(R.id.myList);
mAdapter = new MyCustomAdapter(
this,
R.layout.my_list_row,
null, // cursor set later by cursorloader
mTheme); //int selected theme
lv.setAdapter(mAdapter);
}
User can change theme from preference, in onResume() I check if theme has been changed, in this case actually I repete the above code, creating a new MyCustomAdapter.
My question is: can I use the existent Adapter changing one parameter and updating it? For example when cursor change I use
mAdapter.swapCursor(cursor);
Set your theme in your
getView()ofAdapter,then you can call
in
onResume()ofActivitybut make sure you set your theme as the way you set view data for individual row.
for example:
setTheme()may be a static method in yourUtilsclass which sets the text color or background of your row. or you can set theme insidegetView()also.