alamkanak / Android-Week-View

Android Week View is an android library to display calendars (week view or day view) within the app. It supports custom styling.
Apache License 2.0
3.42k stars 1.23k forks source link

NullpointerException #377

Open masterofn1 opened 7 years ago

masterofn1 commented 7 years ago

Upon carefully following the given instructions, I added the gradle dependency. On the moment I am calling the view component on a layout file, I got a null pointer exception.

entropitor commented 7 years ago

Can you add steps to reproduce this? And preferably also some code

masterofn1 commented 7 years ago
  1. Import dependency via gradle compile 'com.github.alamkanak:android-week-view:1.2.6'
  2. Add weekview on layout file

<com.alamkanak.weekview.WeekView android:id="@+id/weekView" android:layout_width="match_parent" android:layout_height="match_parent" ..........................................................

Then, I got these error image

EvanCooper9 commented 7 years ago

getting the same thing here unfortunately

mzee96 commented 7 years ago

Also getting the same error here

furqankhwaja commented 7 years ago

Same issue. Pls give solutions soon

camsiabor commented 7 years ago

Is the problem related to WeekView.java line 969 -> throw new IllegalStateException("You must provide a MonthChangeListener")?

Pralo commented 7 years ago

I was able to solved this:

You must provide a MonthChangeListener in which you should return at least an empty List of WeekViewEvent Class:

screen shot 2016-10-26 at 10 28 14 am

EvanCooper9 commented 7 years ago

@Pralo Yes you're right. In the example app, the BaseActivity class is meant to implement the MonthChangeListener method but never does (you can see that the method is actually implemented in the BasicActivity class.) Having the MonthChangeListener in the right class fixes the issue.

NOTE: You do get a Null Pointer Exception when looking at the XML in the editor, but it fixes it's self when you run on an emulator or a real device.

lakshaya22 commented 7 years ago

Hello, can you specify the solution in some more detail, as I am having this issue still.

dlucidone commented 7 years ago

In the sample app change BasicActivity. java file content to the below content

import com.alamkanak.weekview.WeekViewEvent; import java.util.ArrayList; import java.util.Calendar; import java.util.List; import com.alamkanak.weekview.MonthLoader;

public class BasicActivity extends BaseActivity implements MonthLoader.MonthChangeListener { @Override public List<? extends WeekViewEvent> onMonthChange(int newYear, int newMonth) { List<WeekViewEvent> events = new ArrayList<WeekViewEvent>(); return events; } }

Hope this Help!