[Solved] How can i simplify this java Statement


Where do You set color for the selected item? is it possible to set all colors to white and then use switch to set only the selected one to desired color?
It would make it at least more pleasant to look at.

nav_news_bg.setBackground(color);
nav_feed_bg.setBackground(color);
nav_profile_bg.setBackground(color);
nav_chat_bg.setBackground(color);
nav_books_bg.setBackground(color);

switch(v.getId()){
    case R.id.nav_news:
        nav_news_bg.setBackground(desiredColor);
        break;
    case R.id.nav_feed:
    .
    .
    .
}

After Your edit it would be best to drop any logic from clean and leave it only as

private void clean(View v) {
    ColorDrawable color = new ColorDrawable(ContextCompat.getColor(this,R.color.white));
    nav_news_bg.setBackground(color);
    nav_feed_bg.setBackground(color);
    nav_profile_bg.setBackground(color);
    nav_chat_bg.setBackground(color);
    nav_books_bg.setBackground(color);
}

because background color is set after this method is executed.

2

solved How can i simplify this java Statement