2016-12-31 81 views
-2

我正在嘗試爲我的應用程序創建導航欄,我突然收到此錯誤消息。並且我還收到了發現週期性鏈的錯誤消息:activity_item_list includes app_bar_main includes activity_item_list 順便說一下,navigation_drawer_open的id在strings.xml中,但仍然收到錯誤消息。任何幫助將很樂意欣賞。錯誤:(86,48)錯誤:無法找到符號變量navigation_drawer_open

的strings.xml

<resources> 
    <string name="navigation_drawer_open">Open navigation drawer</string> 
    <string name="navigation_drawer_close">Close navigation drawer</string> 
</resources> 

app_bar_main.xml

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     app:popupTheme="@style/AppTheme.PopupOverlay" /> 

</android.support.design.widget.AppBarLayout> 

<include layout="@layout/activity_item_list" /> 

<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom|end" 
    android:layout_margin="@dimen/fab_margin" 
    app:srcCompat="@android:drawable/ic_dialog_email" /> 

activity_main_list.xml

<android.support.design.widget.NavigationView 
    android:id="@+id/nav_view" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:fitsSystemWindows="true" 
    app:headerLayout="@layout/nav_header_main" 
    app:menu="@menu/activity_main_drawer" /> 


<android.support.design.widget.AppBarLayout 
    android:id="@+id/app_bar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:background="?attr/colorPrimaryDark" 
     android:layout_width="match_parent" 
     android:layout_height="72dp" 
     android:fitsSystemWindows="true" 
     app:popupTheme="@style/Theme.AppCompat.DayNight.DarkActionBar" /> 

</android.support.design.widget.AppBarLayout> 

<FrameLayout 
    android:id="@+id/frameLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <EditText 
      android:id="@+id/search_box" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="16dp" 
      android:layout_marginRight="16dp" 
      android:layout_marginTop="8dp" 
      android:layout_marginBottom="8dp" 
      android:paddingLeft="8dp" 
      android:paddingBottom="12dp" 
      android:paddingTop="12dp" 
      android:textSize="14sp" 
      android:hint="@string/search_hint" 
      android:background="@drawable/bottom_border" 
      android:layout_alignParentTop="true" 
      android:layout_centerHorizontal="true" /> 

     <include 
      layout="@layout/item_list" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_above="@+id/relativeAd" 
      android:layout_below="@+id/search_box" /> 

     <LinearLayout 
      android:id="@+id/relativeAd" 
      android:layout_width="match_parent" 
      android:layout_height="60dp" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true" 
      android:background="@color/divider" 
      android:gravity="center" 
      android:orientation="vertical"> 
     </LinearLayout> 
    </RelativeLayout> 
</FrameLayout> 

回答

0

您必須添加下面的事情strings.xml文件。

<string name="navigation_drawer_open">Drawer Open</string> 
<string name="navigation_drawer_close">Drawer Closed</string> 
+0

@ user7062312當我定義並重新清理和重建項目時,更改您的字符串值。 – Ironman

+0

我仍然得到相同的錯誤。 – user7062312

+0

@ user7062312轉到'File> InValidate caches and Restart'。 – Ironman

相關問題