i have code,which one if clicked,my textview color are changed,but it only change 1 line.. i want to change all list item color enter image description here
here is my screenshoot this is my code i dont know what's wrong with this code,
PS:its not even i press the button,sometimes if i scroll listview,the color change by itself
public void colorToggle(View view) {
int[] attrs = {android.R.attr.popupBackground};
TypedArray ta = obtainStyledAttributes(R.style.MyApp_PopupMenu, attrs);
final LinearLayout propLayout = (LinearLayout) findViewById(R.id.leot);
ListView listView = (ListView) findViewById(android.R.id.list);
TextView textView = (TextView) findViewById(R.id.wilayah);
switch (view.getId()) {
case R.id.blueButton: {
int holoBlue = getResources().getColor(R.color.holo_blue_light);
mFab.setColor(holoBlue);
getActionBar().setBackgroundDrawable(new ColorDrawable(holoBlue));
mFab.setDrawable(getResources().getDrawable(R.drawable.ic_popup_sync_6));
int popupBackground = ta.getColor(0, R.color.holo_blue_light);
Log.i("Retrieved textColor as hex:", Integer.toHexString(popupBackground));
propLayout.setVisibility(View.GONE);
listView.setDivider(new ColorDrawable(holoBlue));
listView.setDividerHeight(1);
textView.setTextColor(holoBlue);
break;
}
case R.id.purpleButton: {
int holoPurple = getResources().getColor(R.color.holo_purple);
mFab.setColor(holoPurple);
getActionBar().setBackgroundDrawable(new ColorDrawable(holoPurple));
mFab.setDrawable(getResources().getDrawable(R.drawable.ic_popup_sync_6));
int popupBackground = ta.getColor(0, R.color.holo_purple);
Log.i("Retrieved textColor as hex:", Integer.toHexString(popupBackground));
propLayout.setVisibility(View.GONE);
listView.setDivider(new ColorDrawable(holoPurple));
listView.setDividerHeight(1);
textView.setTextColor(holoPurple);
break;
}
case R.id.greenButton: {
int holoGreen = getResources().getColor(R.color.holo_green_light);
mFab.setColor(holoGreen);
getActionBar().setBackgroundDrawable(new ColorDrawable(holoGreen));
mFab.setDrawable(getResources().getDrawable(R.drawable.ic_popup_sync_6));
int popupBackground = ta.getColor(0, R.color.holo_green_light);
Log.i("Retrieved textColor as hex:", Integer.toHexString(popupBackground));
propLayout.setVisibility(View.GONE);
listView.setDivider(new ColorDrawable(holoGreen));
listView.setDividerHeight(1);
textView.setTextColor(holoGreen);
break;
}
case R.id.orangeButton: {
int holoOrange = getResources().getColor(R.color.holo_orange_light);
mFab.setColor(holoOrange);
getActionBar().setBackgroundDrawable(new ColorDrawable(holoOrange));
mFab.setDrawable(getResources().getDrawable(R.drawable.ic_popup_sync_6));
int popupBackground = ta.getColor(0, R.color.holo_orange_light);
Log.i("Retrieved textColor as hex:", Integer.toHexString(popupBackground));
propLayout.setVisibility(View.GONE);
listView.setDivider(new ColorDrawable(holoOrange));
listView.setDividerHeight(1);
textView.setTextColor(holoOrange);
break;
}
case R.id.redButton: {
int holoRed = getResources().getColor(R.color.holo_red_light);
mFab.setColor(holoRed);
getActionBar().setBackgroundDrawable(new ColorDrawable(holoRed));
mFab.setDrawable(getResources().getDrawable(R.drawable.ic_popup_sync_6));
int popupBackground = ta.getColor(0, R.color.holo_red_light);
Log.i("Retrieved textColor as hex:", Integer.toHexString(popupBackground));
propLayout.setVisibility(View.GONE);
listView.setDivider(new ColorDrawable(holoRed));
listView.setDividerHeight(1);
textView.setTextColor(holoRed);
break;
}
}
ta.recycle();
}