Hi, I did evething on chapter 10 and my program fails after adding task to ListDetailActivity I got “ListMaker has stopped” in log I’ve:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.danieldominiak.listmaker, PID: 15365
java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.TextView
at com.example.danieldominiak.listmaker.ListItemViewHolder.(ListItemViewHolder.kt:8)
at com.example.danieldominiak.listmaker.ListItemsRecyclerViewAdapter.onCreateViewHolder(ListItemsRecyclerViewAdapter.kt:11)
(…)
Judging from the log, the app is using a LinearLayout as a TextView. That’s why it fails with the following error:
java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.TextView
The log also says it’s happening in ListItemViewHolder.kt.
My advice to fix the problem is to check a TextView is setup in ListItemViewHolder.kt. If there is, make sure the TextView uses the correct id from the view holder xml layout.
Let me know how you get on. If the problem still continues we can look at alternative solutions.
Hi, thank you for your answer, I was looking only on code side, Iknew the problem is with casting object, but I didnt check names of items. I thought that if they are not red in code they are ok ;).
The problem was in my task_view_holder.xml file, I put the same name (“textview_task”) for two items: for container LinearLayout and for its object TextView.
I’ve change name for LinearLayout and everything is ok. ;).
Taking advantage of the opportunity, I have one more question: I’ve loaded yours final version program of chapter 10 and I’m trying to run it but I’ve error on building “ERROR: Failed to find target with hash string ‘android-26’”. I know I can install ‘android-26’ and later 26.02 …, But is there any possibility to change android version avoiding downloading libraries?