gpt4 book ai didi

java - 在 >=23 中膨胀类 Seekbar 时出错

转载 作者:行者123 更新时间:2023-11-30 10:33:53 25 4
gpt4 key购买 nike

我的代码在 kitkat 中运行,没有异常(exception)。棉花糖出现以下错误。

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 中,我自定义了我的 SeekBar,在 drawable 和 drawable-v21 中都添加了 drawable 文件。 Drawble 文件不是图像和 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" />

drawable 是 -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>

最佳答案

谢谢大家问题已解决。在棉花糖中我无法将拇指添加为 svg :|所以我删除了 android:thumb="@drawable/thumbb" 这个属性,代码现在正在运行

关于java - 在 >=23 中膨胀类 Seekbar 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41972486/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com