По какой-то причине приложение не может найти вид. Но в то же время все представления были правильно проинициализированы. Это диалог, который включает в себя список блесен. Этот диалог вызывает из активности с viewPager, который включает в себя два фрагмента. Пожалуйста, дайте мне знать, если у вас есть идея, где проблема может быть.
class FilterDialogFragment : MvpAppCompatDialogFragment(), FilterView {
@Inject
@InjectPresenter
lateinit var presenter: FilterDialogPresenter
@ProvidePresenter fun provideFilterDialogPresenter() = presenter
@BindViews(R.id.spinner_gender_ni, R.id.spinner_age_ni, R.id.spinner_country,
R.id.spinner_relationship_statuses, R.id.spinner_body_types, R.id.spinner_ethnicities,
R.id.spinner_faith_types, R.id.spinner_smoke_statuses, R.id.spinner_drink_statuses,
R.id.spinner_have_kids_statuses, R.id.spinner_want_kids_statuses)
lateinit var spinners: List<@JvmSuppressWildcards Spinner>
private lateinit var filterListener: FilterListener
interface FilterListener {
fun onUpdate()
}
override fun onCreate(savedInstanceState: Bundle?) {
requireActivity().component.inject(this)
super.onCreate(savedInstanceState)
}
override fun onAttach(context: Context?) {
super.onAttach(context)
if (context is FilterListener) {
filterListener = context
}
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
dialog.window!!.requestFeature(Window.FEATURE_NO_TITLE)
val view = inflater.inflate(R.layout.dialog_filters, container, false)
ButterKnife.bind(this, view)
return view
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
presenter.getSavedValues()
}
override fun onResume() {
super.onResume()
dialog.window!!.setLayout(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT)
}
@OnClick(R.id.button_search)
fun onSearchClicked() {
presenter.saveValues(spinners)
filterListener.onUpdate()
dismiss()
}
@OnClick(R.id.button_cancel)
fun onCancelClicked() {
dismiss()
}
override fun getSavedValues(stringList: List<String>, resIdList: List<Int>) {
for (i in stringList.indices) {
if (presenter.isNotDefault(stringList[i])) {
spinners[i].setSelection(getIndexOfElement(resIdList[i], stringList[i]))
}
}
}
private fun getIndexOfElement(@ArrayRes resId: Int, value: String): Int {
val list = Arrays.asList(*resources.getStringArray(resId))
return list.indexOf(value)
}
companion object {
var TAG = "Dialog Fragment"
}
Сообщение об ошибке
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp, PID: 18357
java.lang.IllegalStateException: Required view 'spinner_age_mi' with ID 2131296837 for field 'spinners' was not found. If this view is optional add '@Nullable' (fields) or '@Optional' (methods) annotation.
at butterknife.internal.Utils.findRequiredView(Utils.java:92)
at butterknife.internal.Utils.findRequiredViewAsType(Utils.java:104)
at com.myapp.mvp.ui.filter.FilterDialogFragment_ViewBinding.<init>(FilterDialogFragment_ViewBinding.java:43)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at butterknife.ButterKnife.createBinding(ButterKnife.java:199)
at butterknife.ButterKnife.bind(ButterKnife.java:172)
at com.myapp.mvp.ui.filter.FilterDialogFragment.onCreateView(FilterDialogFragment.kt:63)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2439)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:802)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:733)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7762)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)