Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
580 views
in Technique[技术] by (71.8m points)

java - android.widget.FrameLayout cannot be cast to androidx.appcompat.widget.Toolbar Error

I am trying to implement searchview on my activity. But whenever I am using framelayout to contain toolbar and searchview, I am getting error of "android.widget.FrameLayout cannot be cast to androidx.appcompat.widget.Toolbar"

  <FrameLayout
    android:id="@+id/toolbar_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

   <androidx.appcompat.widget.Toolbar
        android:id="@+id/search_toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:elevation="4dp"
        android:fitsSystemWindows="true"
        xmlns:app="http://schemas.android.com/apk/res-auto">
    </androidx.appcompat.widget.Toolbar>

    <com.miguelcatalan.materialsearchview.MaterialSearchView
    android:id="@+id/search_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
    </FrameLayout> 
question from:https://stackoverflow.com/questions/65861863/android-widget-framelayout-cannot-be-cast-to-androidx-appcompat-widget-toolbar-e

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...