SpongeBobSun / mCalendarView

Customizable & Shrinkable Calendar Widget for Android
Apache License 2.0
243 stars 73 forks source link

How to change textcolor of calendar dates. #45

Closed rgk1221 closed 7 years ago

rgk1221 commented 7 years ago

I have tried doing it by setDateCell() method. And i have taken your code as it is. I get an error : android.view.InflateException: Binary XML file line #3: Binary XML file line #3: Error inflating class sun.bob.mcalendarviewtest.DateCellView. Help me change the text color.

SpongeBobSun commented 7 years ago

First create your own view class which extends BaseCellView, implement required functions.

Then create a layout xml, use the class created in step one as the root node of it.

rgk1221 commented 7 years ago

`public class DateCellView extends BaseCellView {

TextView id_cell_text;

public DateCellView(Context context) {
    super(context);
}

public DateCellView(Context context, AttributeSet attrs) {
    super(context, attrs);
}

@Override
public void setDisplayText(DayData day) {

    id_cell_text=  (TextView) this.findViewById(R.id.id_cell_text);
    id_cell_text.setText(day.getText());
}

}`

See. I have created the class same as you have created. ---> " use the class created in step one as the root node of it." WHAT YOU MEAN BY THIS. I CAN'T UNDERSTAND. i am an amateaur. please help me out with this.

rgk1221 commented 7 years ago

calendarView.setDateCell(R.layout.layout_date_cell) I have also done this as you have done in your code

SpongeBobSun commented 7 years ago

<?xml version="1.0" encoding="utf-8"?> <your.package.DateCellView xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="100dp" android:layout_height="100dp" android:background="#00ADA3"> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:textColor="#FFFFFF" android:id="@+id/id_cell_text"/> </your.package.DateCellView>

Also, don't shout.

rgk1221 commented 7 years ago

Hehe. thankyou soo much for your help.

rgk1221 commented 7 years ago

Please i need one more help. when i implemented the datecellview as we discussed, all its styling and sizes changed. Now before implementing this thing the calendar was looking pretty attractive but now because i implemented the view all its styling is gone. i just wanted to change the text color of the dates. I was successful in changing the textcolor but then now its looking very ugly. So is there any way i could change only the textcolor of the dates and have the previous calendar with only its textcolor changed????

SpongeBobSun commented 7 years ago

You should copy or modify my code.

See - https://github.com/SpongeBobSun/mCalendarView/blob/master/mcalendarview/src/main/java/sun/bob/mcalendarview/views/DefaultCellView.java

for example.

Or, you should "styling" your own date cell xml.