You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am receiving a noSuchMethodException when trying to inflate the month view. It's easy to reproduce with a blank project and adding this view to the main activity:
Here is the part of the stack trace that I believe is important:
Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class jp.co.recruit_mp.android.lightcalendarview.MonthView
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class jp.co.recruit_mp.android.lightcalendarview.MonthView
Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet]
/**
* 月カレンダーを表示する {@link LinearLayout}
* Created by masayuki-recruit on 8/19/16.
*/
class MonthView(context: Context, private val settings: CalendarSettings, var month: Date) : LinearLayout(context), DayLayout.Callback {
internal var callback: Callback? = null
private val weekDayLayout: WeekDayLayout
private val dayLayout: DayLayout
init {
orientation = LinearLayout.VERTICAL
weekDayLayout = WeekDayLayout(context, settings)
addView(weekDayLayout, LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
dayLayout = DayLayout(context, settings, month).apply { callback = this@MonthView }
addView(dayLayout, LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
}
override fun onDateSelected(date: Date) {
callback?.onDateSelected(date)
}
fun setSelectedDate(date: Date) {
dayLayout.setSelectedDay(date)
}
fun setAccents(date: Date, accents: Collection<Accent>) = dayLayout.let {
it.getDayView(date)?.setAccents(accents)
it.invalidateDayViews()
}
fun setAccents(map: Map<Date, Collection<Accent>>) {
map.forEach { it ->
val (date, accents) = it
dayLayout.getDayView(date)?.setAccents(accents)
}
dayLayout.invalidateDayViews()
}
interface Callback {
fun onDateSelected(date: Date)
}
override fun toString(): String = "MonthView(${month})"
}
Here is the full stack trace:
11-08 12:26:16.061 4539-4539/com.thomascoook.testbed E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.thomascoook.testbed, PID: 4539
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thomascoook.testbed/com.thomascoook.testbed.MainActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class jp.co.recruit_mp.android.lightcalendarview.MonthView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class jp.co.recruit_mp.android.lightcalendarview.MonthView
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class jp.co.recruit_mp.android.lightcalendarview.MonthView
Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet]
at java.lang.Class.getConstructor0(Class.java:2204)
at java.lang.Class.getConstructor(Class.java:1683)
at android.view.LayoutInflater.createView(LayoutInflater.java:618)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.thomascoook.testbed.MainActivity.onCreate(MainActivity.kt:10)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
The text was updated successfully, but these errors were encountered:
I am receiving a noSuchMethodException when trying to inflate the month view. It's easy to reproduce with a blank project and adding this view to the main activity:
Here is the part of the stack trace that I believe is important:
And when I look at the source code for your view I can see the problem is you are not supplying the required constructors as per this StackOverflow post and and my own experience: https://stackoverflow.com/questions/11753719/how-do-i-properly-extend-a-layout-class.
The library class in question:
Here is the full stack trace:
The text was updated successfully, but these errors were encountered: