prompt: after the article is written, the directory can be automatically generated. For how to generate it, please refer to the help document on the right </ font> for details
Java.lang.classcastexception encountered when using viewbinding: android.widget.relativelayout cannot be cast to cast to android.widget.textview
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/back"
android:layout_margin="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Back" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Title"
android:textSize="20sp" />
<Button
android:id="@+id/done"
android:layout_margin="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="Done" />
</RelativeLayout>
In the XML of the title, the ID of textview is title
<include
android:id="@+id/title"
layout="@layout/titlebar" />
Use include < in the main interface> When introducing a layout, the layout ID set is also the title,
when using viewbinding, there will be confusion, so the ID name should be set to different.
Read More:
- How to Solve Error inflating class android.support.design.widget.FloatingActionButton
- [Solved] error: package android.support.design.widget does not exist
- How to Solve Error: Android java.lang.IllegalStateException: Could not execute method of the activity
- Runtime error prompt in Android Studio: arrayadapter requires the resource ID to be a textview problem
- [Solved] Android DataBinding Error: java.lang.ArrayIndexOutOfBoundsException: length=2; index=2 fragment Changes to Fragm
- [Solved] Android mediaplayer.prepare() Error: Caused by: java.lang.IllegalStateException
- [Solved] Android Error: java.lang.IllegalStateException: Not allowed to start service Intent
- [Solved] Unreal Engine Error: Widget Blueprint could not be loaded because it derives from an invalid class
- [Solved] Android MediaRecorder.stop() Error: java.lang.RuntimeException: stop failed.
- Java.lang.AbstractMethodError: org.mybatis.spring.transaction.SpringManagedTransaction.getTimeout()Ljava/lang/Integer; error resolution
- [Solved] java.lang.reflect.InaccessibleObjectException: Unable to make protected java.net.http.HttpRequest()…
- The SDK of Android webrtc compiled with Ninja – C out / release command reported an error, and the Android NDK processing method could not be found
- [Solved] AS Warning: String literal in setText can not be translated. Use Android resources instead.
- [Solved] Flutter Error: No MediaQuery widget ancestor found.
- [Solved] Android9.0 App Install Android4.4 Error: InflateException-You must supply a layout_height attribute.
- Idea Error: java: java.lang.OutOfMemoryError: GC overhead limit exceeded
- Hive ERROR Failed with exception java.io.IOException:java.lang.IllegalArgumentException
- [Solved] Response Export error on submit request on future invoke, java.lang.OutOfMemoryError: Java heap space