2017-02-01 214 views
1

我的代碼在kitkat中工作,沒有例外。以下錯誤發生在棉花糖。錯誤膨脹類Seekbar> = 23

的Java文件

class MyServAdapter extends RecyclerView.Adapter<MyServAdapter.MyViewHolder> { 
    int icons_red[] = {R.drawable.red_service, R.drawable.red_tire, R.drawable.red_oil_car, R.drawable.red_pollutn, R.drawable.red_car_insurance}; 

    public class MyViewHolder extends RecyclerView.ViewHolder { 
     public TextView sevice_name, due_time; 
     public ImageView img; 
     public SeekBar seekBar; 

     public MyViewHolder(View view) { 
      super(view); 
      sevice_name = (TextView) view.findViewById(R.id.serv_name); 
      due_time = (TextView) view.findViewById(R.id.due_date); 
      // servi_time_words = (TextView) view.findViewById(R.id.serv_time_in_words); 
      img = (ImageView) view.findViewById(R.id.serv_icon); 
      seekBar = (SeekBar) view.findViewById(R.id.serv_progress); 
     } 
    } 

    public MyServAdapter(ServiceDetail service_detail) { 
     this.service_detail = service_detail; 
    } 

    @Override 
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 
     View itemView = LayoutInflater.from(parent.getContext()) 
        .inflate(R.layout.custom_service_item, parent, false); //here i'm getting error 
     return new MyViewHolder(itemView); 
    } 
} 

錯誤日誌

FATAL EXCEPTION: main 
Process: com.eoninfotech.eurotrack, PID: 19864 
    android.view.InflateException: Binary XML file line #39: Binary XML file line #39: Error inflating class SeekBar 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:551) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
    at com.eoninfotech.eurotrack.Fragmentss.MyServAdapter.onCreateViewHolder(MyServAdapter.java:53) 
    at com.eoninfotech.eurotrack.Fragmentss.MyServAdapter.onCreateViewHolder(MyServAdapter.java:24) 
    at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5836) 
    at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5060) 
    at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4970) 
    at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2029) 
    at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1414) 
    at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1377) 
    at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:578) 
    at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3315) 
    at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3124) 
    at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3568) 
    at android.view.View.layout(View.java:17993) 
    at android.view.ViewGroup.layout(ViewGroup.java:5817) 
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742) 
    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585) 
    at android.widget.LinearLayout.onLayout(LinearLayout.java:1494) 
    at android.view.View.layout(View.java:17993) 
    at android.view.ViewGroup.layout(ViewGroup.java:5817) 
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344) 
    at android.widget.FrameLayout.onLayout(FrameLayout.java:281) 
    at android.view.View.layout(View.java:17993) 
    at android.view.ViewGroup.layout(ViewGroup.java:5817) 
    at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:131) 
    at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42) 
    at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1364) 
    at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:846) 
    at android.view.View.layout(View.java:17993) 
    at android.view.ViewGroup.layout(ViewGroup.java:5817) 
    at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1197) 
    at android.view.View.layout(View.java:17993) 
    at android.view.ViewGroup.layout(ViewGroup.java:5817) 
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344) 
    at android.widget.FrameLayout.onLayout(FrameLayout.java:281) 
    at android.view.View.layout(View.java:17993) 
    at android.view.ViewGroup.layout(ViewGroup.java:5817) 
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742) 
    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585) 
    at android.widget.LinearLayout.onLayout(LinearLayout.java:1494) 
    at android.view.View.layout(View.java:17993) 
    at android.view.ViewGroup.layout(ViewGroup.java:5817) 
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344) 
    at android.widget.FrameLayout.onLayout(FrameLayout.java:281) 
    at android.view.View.layout(View.java:17993) 
    at android.view.ViewGroup.layout(ViewGroup.java:5817) 
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742) 
    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585) 
    at android.widget.LinearLayout.onLayout(LinearLayout.java:1494) 
    at android.view.View.layout(View.java:17993) 
    at android.view.ViewGroup.layout(ViewGroup.java:5817) 
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344) 
    at android.widget.FrameLayout.onLayout(FrameLayout.java:281) 
    at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:3172) 
    at android.view.View.layout(View.java:1 

在我的XML定製自己的搜索欄,提拉文件中都繪製和drawable-v21增加。 Drawable文件不是它的圖像和XML文件。

<SeekBar 
    android:id="@+id/serv_progress" 
    android:layout_width="match_parent" 
    android:layout_height="7dp" 
    android:max="100" 
    android:progressDrawable="@drawable/custom_progressbar" 
    android:thumb="@drawable/thumbb" /> 

繪製是-custom_progressbar.xml:

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 

    <item android:id="@android:id/background"> 
     <shape android:shape="rectangle" > 
      <corners android:radius="5dp" /> 

      <gradient 

       android:endColor="#979797" 
       android:startColor="#979797" /> 
     </shape> 
    </item> 
    <item android:id="@+id/progressshape"> 
     <clip> 
      <shape android:shape="rectangle" > 
       <corners android:radius="5dp" /> 

       <gradient 

        android:endColor="@color/red" 
        android:centerColor="#ffea03" 
        android:startColor="#27e883" /> 
      </shape> 
     </clip> 
    </item> 

</layer-list> 
+0

您要添加的圖像的大小是多少? – OBX

+0

顯示您可繪製的xml –

+1

從'drawable'文件夾中檢查您的圖像。它是高分辨率圖像嗎?因爲如果其中一個資源具有較高的像素分辨率,則需要大量內存,導致出現充氣異常 – Piyush

回答

0

三江源所有 問題是solved.In棉花糖我不能添加拇指SVG:| 因此,我刪除android:thumb="@drawable/thumbb"此屬性和代碼現在正在運行

相關問題