gpt4 book ai didi

java - android.view.InflateException : Binary XML file line #10

转载 作者:太空宇宙 更新时间:2023-11-04 10:10:34 25 4
gpt4 key购买 nike

我正在尝试使用 Yasic 创建粒子 TextView 动画库,但是当我在物理设备上运行代码时,出现膨胀异常错误。我还没有弄清楚问题所在,如果您向我展示一些解决此错误的方法,这将是一个很大的帮助。

这是我的java代码

Java

public class MainActivity extends AppCompatActivity {


@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

@Override
protected void onResume() {
super.onResume();
ParticleTextView particleTextView1 = (ParticleTextView) findViewById(R.id.particleTextView1);
ParticleTextViewConfig config1 = new ParticleTextViewConfig.Builder()
.setTargetText("Loading")
.setReleasing(0.4)
.setParticleRadius(4)
.setMiniDistance(1)
.setTextSize(150)
.setRowStep(9)
.setColumnStep(9)
.instance();


particleTextView1.setConfig(config1);
particleTextView1.startAnimation();

}
}

此处出现 Logcat 错误

Logcat

09-18 22:31:52.809 7418-7418/com.codecrafted.udit.particle E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.codecrafted.udit.particle, PID: 7418
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.codecrafted.udit.particle/com.codecrafted.udit.particle.MainActivity}: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class com.yasic.library.particletextview.View.ParticleTexView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2747)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2808)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1541)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:165)
at android.app.ActivityThread.main(ActivityThread.java:6365)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:883)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
Caused by: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class com.yasic.library.particletextview.View.ParticleTexView
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class com.yasic.library.particletextview.View.ParticleTexView
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.yasic.library.particletextview.View.ParticleTexView" on path: DexPathList[[zip file "/data/app/com.codecrafted.udit.particle-2/base.apk"],nativeLibraryDirectories=[/data/app/com.codecrafted.udit.particle-2/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.view.LayoutInflater.createView(LayoutInflater.java:613)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:812)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:752)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:883)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at android.view.LayoutInflater.inflate(LayoutInflater.java:522)
at android.view.LayoutInflater.inflate(LayoutInflater.java:430)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.codecrafted.udit.particle.MainActivity.onCreate(MainActivity.java:38)
at android.app.Activity.performCreate(Activity.java:6852)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2700)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2808)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1541)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:165)
at android.app.ActivityThread.main(ActivityThread.java:6365)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:883)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)

最佳答案

首先在onCreate()方法中初始化ParticleTextView

private ParticleTextView particleTextView1
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

particleTextView1 = (ParticleTextView) findViewById(R.id.particleTextView1);
}

然后在您的 xml 中,确保其开头为:

<com.yasic.library.particletextview.View.ParticleTextView

我猜测在 onResume() 方法中初始化 View 可能会导致此问题,因为它可能不会在第一次运行时在 onCreate() 方法中创建。

关于java - android.view.InflateException : Binary XML file line #10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52391702/

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