Строка двоичного XML-файла № 17: Ошибка надувания класса <unknown> - непредсказуемая ошибка
Я пытаюсь надуть макет на нестандартный адаптер в getView(...)
метод, но иногда я получаю ошибку в заголовке. Я уже пытался найти похожие вопросы здесь, но не нашел решения, которое бы сработало для меня. Эта ошибка странная, потому что это происходит только иногда и только на некоторых устройствах - полный журнал ниже
android.view.InflateException: Binary XML file line #17: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:606)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at cz.anywhere.sochi.adapter.NewsAdapter.getView(NewsAdapter.java:35)
at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:220)
at android.widget.AbsListView.obtainView(AbsListView.java:2040)
at android.widget.ListView.makeAndAddView(ListView.java:1772)
at android.widget.ListView.fillDown(ListView.java:672)
at android.widget.ListView.fillSpecific(ListView.java:1330)
at android.widget.ListView.layoutChildren(ListView.java:1603)
at android.widget.AbsListView.onLayout(AbsListView.java:1870)
at android.view.View.layout(View.java:11418)
at android.view.ViewGroup.layout(ViewGroup.java:4328)
at android.widget.FrameLayout.onLayout(FrameLayout.java:443)
at android.view.View.layout(View.java:11418)
at android.view.ViewGroup.layout(ViewGroup.java:4328)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1652)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1510)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1415)
at android.view.View.layout(View.java:11418)
at android.view.ViewGroup.layout(ViewGroup.java:4328)
at android.widget.FrameLayout.onLayout(FrameLayout.java:443)
at android.view.View.layout(View.java:11418)
at android.view.ViewGroup.layout(ViewGroup.java:4328)
at android.widget.FrameLayout.onLayout(FrameLayout.java:443)
at android.view.View.layout(View.java:11418)
at android.view.ViewGroup.layout(ViewGroup.java:4328)
at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1589)
at android.view.View.layout(View.java:11418)
at android.view.ViewGroup.layout(ViewGroup.java:4328)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1652)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1510)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1415)
at android.view.View.layout(View.java:11418)
at android.view.ViewGroup.layout(ViewGroup.java:4328)
at android.widget.FrameLayout.onLayout(FrameLayout.java:443)
at android.view.View.layout(View.java:11418)
at android.view.ViewGroup.layout(ViewGroup.java:4328)
at android.widget.FrameLayout.onLayout(FrameLayout.java:443)
at android.view.View.layout(View.java:11418)
at android.view.ViewGroup.layout(ViewGroup.java:4328)
at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:690)
at android.view.View.layout(View.java:11418)
at android.view.ViewGroup.layout(ViewGroup.java:4328)
at android.widget.FrameLayout.onLayout(FrameLayout.java:443)
at android.view.View.layout(View.java:11418)
at android.view.ViewGroup.layout(ViewGroup.java:4328)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1652)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1510)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1415)
at android.view.View.layout(View.java:11418)
at android.view.ViewGroup.layout(ViewGroup.java:4328)
at android.widget.FrameLayout.onLayout(FrameLayout.java:443)
at android.view.View.layout(View.java:11418)
at android.view.ViewGroup.layout(ViewGroup.java:4328)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1489)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.L
Вот исходный код от Адаптера, где я пытаюсь надуть item_news.xml
раскладка.
@Override
public View getView(int position, View v, ViewGroup parent) {
if (v == null) {
v = getInflater().inflate(R.layout.item_news, null);
ViewHolder holder = new ViewHolder();
holder.newsImage = (ImageView) v.findViewById(R.id.news_image);
holder.title = (TextView) v.findViewById(R.id.news_title);
holder.date = (TextView) v.findViewById(R.id.news_date);
holder.progressBar = (ProgressBar) v.findViewById(R.id.news_progress);
holder.source = (ImageView) v.findViewById(R.id.news_source_logo);
v.setTag(holder);
}
final ViewHolder h = (ViewHolder) v.getTag();
final News news = getItem(position);
if(news.getImage() == null){
//TODO - if image isn't available illustration photo must be shown
h.progressBar.setVisibility(View.GONE);
}else{
Picasso.with(getContext()).load(SochiApp.BASE_URL + news.getImage().getSmall()).into(h.newsImage, new Callback() {
@Override
public void onSuccess() {
h.progressBar.setVisibility(View.GONE);
}
@Override
public void onError() {
SochiLog.e(TAG, SochiApp.BASE_URL + news.getImage().getSmall() + " load image error");
h.progressBar.setVisibility(View.GONE);
}
});
}
h.title.setText(news.getTitle());
h.date.setText(news.getDate_create());
String category = news.getCategory();
h.source.setVisibility(View.GONE);
if(category.equals(FiltrPreferences.NEWS)){
// h.source.setImageResource(R.drawable.news_logo);
}else if(category.equals(FiltrPreferences.EXCLUSIVE)){
h.source.setImageResource(R.drawable.exclusive_logo);
h.source.setVisibility(View.VISIBLE);
}else if(category.equals(FiltrPreferences.LETNA)){
// h.source.setImageResource(R.drawable.czech_official_logo);
}
return v;
}
private static class ViewHolder {
ImageView newsImage;
ProgressBar progressBar;
TextView title;
TextView date;
ImageView source;
}
А также item_news.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:padding="10dp"
android:layout_height="130dp">
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent">
<ImageView
android:id="@+id/news_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/dummy_image" />
<ProgressBar
android:id="@+id/news_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="10dp"
android:orientation="vertical">
<TextView
android:id="@+id/news_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/newsTitle"
android:text="@string/dummy_text" />
<TextView
android:id="@+id/news_date"
android:text="@string/dummy_text"
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<ImageView
android:id="@+id/news_source_logo"
android:adjustViewBounds="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="5dp"
android:layout_marginRight="5dp"
android:layout_width="15dp"
android:src="@drawable/exclusive_logo"
android:layout_height="wrap_content" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
Ошибка происходит на @+id/news_image
ImageView, но он появляется непредсказуемо и только на некоторых устройствах (на Galaxy S4 с Android 4.3 все работает, но на Galaxy S3 Android 4.1.2 приложение иногда вылетает из-за этой ошибки)
Спасибо за помощь.