GithubHelp home page GithubHelp logo

Comments (13)

fenwind avatar fenwind commented on July 23, 2024 4

(⊙o⊙)哦已经 解决了,这个控件很不错。收藏了哈哈

from supercalendar.

MagicMashRoom avatar MagicMashRoom commented on July 23, 2024

at calendar.oa.com.myapplication.MainActivity.initCalendarView(MainActivity.java:114)
把你的MainActivity代码截个图看一下吧

from supercalendar.

1277379283 avatar 1277379283 commented on July 23, 2024

image

from supercalendar.

MagicMashRoom avatar MagicMashRoom commented on July 23, 2024

麻烦再把CustomDayView的全部代码发一下吧

from supercalendar.

1277379283 avatar 1277379283 commented on July 23, 2024

package calendar.oa.com.myapplication;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ldf.calendar.Utils;
import com.ldf.calendar.component.State;
import com.ldf.calendar.interf.IDayRenderer;
import com.ldf.calendar.model.CalendarDate;
import com.ldf.calendar.view.DayView;

/**

  • Created by ldf on 17/6/26.
    */

public class CustomDayView extends DayView {

private TextView dateTv;
private ImageView marker;
private View selectedBackground;
private View todayBackground;
private final CalendarDate today = new CalendarDate();

/**
 * Constructor. Sets up the MarkerView with a custom layout resource.
 *
 * @param context
 * @param layoutResource the layout resource to use for the MarkerView
 */
public CustomDayView(Context context, int layoutResource) {
    super(context, layoutResource);
    final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View  contentView = inflater.inflate(R.layout.custom_day,null);
    dateTv = (TextView) contentView.findViewById(R.id.date);
    marker = (ImageView) contentView.findViewById(R.id.maker);
    selectedBackground = contentView.findViewById(R.id.selected_background);
    todayBackground = contentView.findViewById(R.id.today_background);
}

@Override
public void refreshContent() {
    renderToday(day.getDate());
    renderSelect(day.getState());
    renderMarker(day.getDate(), day.getState());
    super.refreshContent();
}

private void renderMarker(CalendarDate date, State state) {
    if(Utils.loadMarkData().containsKey(date.toString())) {
        if(state == State.SELECT || date.toString().equals(today.toString())) {
            marker.setVisibility(GONE);
        } else {
            marker.setVisibility(VISIBLE);
            if(Utils.loadMarkData().get(date.toString()).equals("0") ){
                marker.setEnabled(true);
            } else {
                marker.setEnabled(false);
            }
        }
    } else {
        marker.setVisibility(GONE);
    }
}

private void renderSelect(State state) {
    if (state == State.SELECT) {
        selectedBackground.setVisibility(VISIBLE);
        dateTv.setTextColor(Color.WHITE);
    } else if(state == State.NEXT_MONTH || state == State.PAST_MONTH) {
        selectedBackground.setVisibility(GONE);
        dateTv.setTextColor(Color.parseColor("#d5d5d5"));
    } else {
        selectedBackground.setVisibility(GONE);
        dateTv.setTextColor(Color.parseColor("#111111"));
    }
}

private void renderToday(CalendarDate date) {
    if(date != null) {
        if(date.equals(today)) {
            dateTv.setText("今");
            todayBackground.setVisibility(VISIBLE);
        } else {
            dateTv.setText(date.day + "");
            todayBackground.setVisibility(GONE);
        }
    }
}

@Override
public IDayRenderer copy() {
    return new CustomDayView(context , layoutResource);
}

}

from supercalendar.

1277379283 avatar 1277379283 commented on July 23, 2024

嗨 我发现 CustomDayView一直获取的控件就是null ,但是 我用了 很多方法 还是不行,有更好的建议嘛?

from supercalendar.

MagicMashRoom avatar MagicMashRoom commented on July 23, 2024

你把你的项目包发过来吧 这么描述我也没法改 QQ 2286767746

from supercalendar.

zhanghangyes avatar zhanghangyes commented on July 23, 2024

同上, CustomDayView customDayView = new CustomDayView(context , R.layout.custom_day);也是返回null

from supercalendar.

PhoenixGJH avatar PhoenixGJH commented on July 23, 2024

我也遇到了这个问题,三星note2,4.3会出这个问题,7.1.1以及8.0不会出现这个问题。

from supercalendar.

fenwind avatar fenwind commented on July 23, 2024

我也遇到了这个问题,4.3会出这个问题,5.1,7.1.1以及8.0不会出现这个问题。

from supercalendar.

JobeReeves avatar JobeReeves commented on July 23, 2024

楼上怎么解决的

from supercalendar.

fenwind avatar fenwind commented on July 23, 2024

qq 20170920173117
加上 红框里的一行

from supercalendar.

JobeReeves avatar JobeReeves commented on July 23, 2024

谢谢,解决了~。貌似是RelativeLayout的一个bug,系统低于4.4.4都会有问题,改为继承LinearLayout就OK了

from supercalendar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.