-1

I am developing a week data application in Android. I would like to set the background color for weekday (example: friday). I am using the listview in xml. Thanks a lot for your suggestions,

 private void addDateView(LinearLayout layout, String text,
        boolean isCurrentDay) {
    listview child = new listview(layout.getContext());



    if (isCurrentDay) {
        child.setBackgroundColor(Color.rgb(242, 199, 125));
    } else {
        child.setBackgroundColor(Color.WHITE);
    }

    child.setGravity(Gravity.CENTER);
    child.setTextColor(Color.RED);
    [enter image description here][1]child.setPadding(8, 8, 8, 8);
    layout.addView(child, (SCREEN_WIDTH / 7), 50);
}
Ankam
  • 25
  • 6
  • what's the problem with this code? It look ok – Gavriel Jan 30 '16 at 23:53
  • Thanks for your reply, I am getting errors with boolean and int. I don't know how to figure out. If you have any code or links that would be great. thanks a lot! – Ankam Jan 30 '16 at 23:55
  • add the full error message to the question, and indicate the lines in your code that appear in the error log – Gavriel Jan 30 '16 at 23:57

1 Answers1

0

To get the day do the following :

Calendar calendar = Calendar.getInstance();
int day = calendar.get(Calendar.DAY_OF_WEEK); 

To set the background according to the day :

switch (day) {
case Calendar.SUNDAY:


case Calendar.MONDAY:

}

And So on, inside the case put your changing logic .

Jaeger
  • 1,646
  • 8
  • 27
  • 59