在listview中使用shamanland fonticon时出现android.view.InflateException

时间:2016-03-29 18:47:26

标签: android listview inflate-exception

我在listview中使用了shamanland fonticon。但是在运行之后我给了我这个错误:

android.view.InflateException: Binary XML file line #10: Error inflating class com.shamanland.fonticon.FontIconTextView

这是我的代码:

item_news.xml

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="match_parent"
    android:background="@drawable/rect_lst_list_news_selector"
    android:paddingLeft="10dp" >


    <com.shamanland.fonticon.FontIconTextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Dummy text"
        app:iconLeft="@xml/ic_clock"
        />


    <TextView
        android:id="@+id/text_date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/fontAwesomeText1"
        android:layout_alignBottom="@+id/fontAwesomeText1"
        android:layout_marginRight="5dp"
        android:layout_toRightOf="@+id/fontAwesomeText1"
        android:paddingTop="5dp"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="#97959B"
        android:textSize="10dp" />

    <com.android.volley.toolbox.NetworkImageView
        android:id="@+id/image_news_thumb"
        android:layout_width="@dimen/news_tumb"
        android:layout_height="@dimen/news_tumb"
        android:scaleType="fitCenter"
        android:layout_below="@+id/text_date"
        android:layout_alignRight="@+id/linearLayout"
        android:layout_alignEnd="@+id/linearLayout">
    </com.android.volley.toolbox.NetworkImageView>

    <com.shamanland.fonticon.FontIconView

        android:id="@+id/fontAwesomeText2"
        android:layout_below="@+id/text_date"
        android:layout_marginTop="15dp"
        android:layout_toLeftOf="@+id/image_news_thumb"
        android:paddingLeft="8dp"
        android:paddingRight="8dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/icon_caretleft"
        android:textSize="@dimen/big_icon_size"
        android:textColor="@color/icon_color2"

        />


    <TextView
        android:id="@+id/text_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/fontAwesomeText2"
        android:layout_toLeftOf="@+id/fontAwesomeText2"
        android:ellipsize="end"
        android:gravity="right"
        android:maxLines="1"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textSize="14sp" />
    <com.shamanland.fonticon.FontIconView
        android:id="@+id/fontAwesomeText3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignRight="@+id/fontAwesomeText2"
        android:layout_below="@+id/fontAwesomeText2"
        android:layout_marginTop="14dp"
        android:paddingLeft="8dp"
        android:paddingRight="8dp"
        android:text="@string/icon_caretleft"
        android:textSize="@dimen/big_icon_size"
        android:textColor="@color/icon_color3"

        />


    <TextView
        android:id="@+id/text_summery"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/fontAwesomeText3"
        android:layout_toLeftOf="@+id/fontAwesomeText3"
        android:ellipsize="end"
        android:gravity="right"
        android:lineSpacingExtra="8dp"
        android:maxLines="4"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="#5A5A61"
        android:textSize="13sp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/text_summery"
        android:layout_centerHorizontal="true"
        android:paddingBottom="6dp"
        android:paddingLeft="6dp"
        android:id="@+id/linearLayout">

        <ImageView
            android:id="@+id/cm_img_bookmar"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:src="@drawable/bookmark" />
    </LinearLayout>

</RelativeLayout>

适配器:

public class NewsListAdapter extends BaseAdapter{



private Activity activity;
private LayoutInflater inflater;
private List<NewsItem> newsItems;

ImageLoader imageLoader = MyApplication.getInstance().getImageLoader();
public NewsListAdapter(Activity activity,List<NewsItem> newsItems){
    this.activity=activity;
    this.newsItems=newsItems;
    inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}


@Override
public int getCount() {
    return newsItems.size();
}

@Override
public Object getItem(int position) {
    return newsItems.get(position);
}

@Override
public long getItemId(int position) {
    return newsItems.get(position).get_id();
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    if (inflater == null)
        inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    if (convertView == null)
        convertView = inflater.inflate(R.layout.item_news, null);
    if (imageLoader == null)
        imageLoader = MyApplication.getInstance().getImageLoader();


    TextView titleHolder= (TextView) convertView.findViewById(R.id.text_title);
    TextView summeryHolder= (TextView) convertView.findViewById(R.id.text_summery);
    TextView dateHolder=(TextView)convertView.findViewById(R.id.text_date);
    NetworkImageView thumbpicHolder = (NetworkImageView) convertView
            .findViewById(R.id.image_news_thumb);

    NewsItem item=newsItems.get(position);
    titleHolder.setText(item.get_title());
    summeryHolder.setText(item.get_summary());

    thumbpicHolder.setImageUrl(item.get_imgPath(), imageLoader);

    String datetime=newsItems.get(position).get_datePublish();
    String date_part=datetime.split(" ")[0];
    String time_part=datetime.split(" ")[1];
    PersianDate pdate = new PersianDate();
    String date_final =String.format("{0}   {1}",pdate.Shamsi(date_part),time_part);
    dateHolder.setText(date_final);




    return convertView;
}

}

logcat

    03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime: FATAL EXCEPTION: main
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime: android.view.InflateException: Binary XML file line #10: Error inflating class com.shamanland.fonticon.FontIconTextView
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.LayoutInflater.createView(LayoutInflater.java:613)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at whc.ir.news.adapter.NewsListAdapter.getView(NewsListAdapter.java:65)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.widget.AbsListView.obtainView(AbsListView.java:2350)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.widget.ListView.makeAndAddView(ListView.java:1937)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.widget.ListView.fillDown(ListView.java:789)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.widget.ListView.fillFromTop(ListView.java:850)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.widget.ListView.layoutChildren(ListView.java:1787)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.widget.AbsListView.onLayout(AbsListView.java:2178)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.View.layout(View.java:13858)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.ViewGroup.layout(ViewGroup.java:4380)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.View.layout(View.java:13858)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.ViewGroup.layout(ViewGroup.java:4380)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.View.layout(View.java:13858)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.ViewGroup.layout(ViewGroup.java:4380)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1627)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.View.layout(View.java:13858)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.ViewGroup.layout(ViewGroup.java:4380)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1037)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:747)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1156)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:760)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.View.layout(View.java:13858)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.ViewGroup.layout(ViewGroup.java:4380)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.View.layout(View.java:13858)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.ViewGroup.layout(ViewGroup.java:4380)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1043)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.View.layout(View.java:13858)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.ViewGroup.layout(ViewGroup.java:4380)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.View.layout(View.java:13858)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.ViewGroup.layout(ViewGroup.java:4380)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.View.layout(View.java:13858)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.ViewGroup.layout(ViewGroup.java:4380)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.View.layout(View.java:13858)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.ViewGroup.layout(ViewGroup.java:4380)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.View.layout(View.java:13858)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.ViewGroup.layout(ViewGroup.java:4380)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.View.layout(View.java:13858)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.ViewGroup.layout(ViewGroup.java:4380)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2123)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1924)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1160)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4682)
03-29 23:02:30.820 27741-27741/whc.ir.news E/AndroidRuntime:    at android.view.Choreograp

我的代码出了什么问题?

0 个答案:

没有答案