This is the method that can display the errors.
The error :
Caused by:
android.view.InflateException: Binary XML file line #0: Error inflating class <unknown>
Caused by:
java.lang.reflect.InvocationTargetException
this code below ,
.inflate(R.layout.item_layout, parent, false);
display the error..
and this is the onCreateViewHolder which has an error.
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int
viewType) {
if (viewType == VIEW_TYPE_ITEM)
{
View view = LayoutInflater.from(activity)
.inflate(R.layout.item_layout, parent, false);
return new ItemViewHolder(view);
}
else if ( viewType == VIEW_TYPE_LOADING){
View view = LayoutInflater.from(activity)
.inflate(R.layout.item_loading, parent, false);
return new LoadingViewHolder(view);
}
return null;
}
and this is the item.layout xml codes! I thought this xml file is related to an error. so I posted this. thanks!!!
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height= "wrap_content"
android:orientation="vertical"
app:cardElevation="10dp"
android:layout_margin="10dp"
>
<LinearLayout
android:orientation="vertical"
android:padding="10dp"
android:layout_width="match_parent"
android:background="?android:selectedWeekBackgroundColor"
android:layout_height="wrap_content">
<TextView
android:id="@+id/txtName"
android:text="Name"
android:textSize="16sp"
android:textColor="@android:color/black"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/txtLength"
android:text="length"
android:textSize="16sp"
android:textColor="@android:color/black"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>