returns an error I have a library project in which I define the action bar in the action_bar.xml layout action...">

Android - <include layout = ... / "> returns an error

I have a library project in which I define the action bar in the action_bar.xml layout action_bar.xml as follows:

  <?xml version="1.0" encoding="utf-8"?> <merge xmlns:android="http://schemas.android.com/apk/res/android"> <LinearLayout style="@style/actionBar" /> </merge> 

Corresponding style element:

 <style name="actionBar"> <item name="android:id">@id/action_bar_container</item> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">@dimen/title_height</item> <item name="android:orientation">horizontal</item> <item name="android:background">@drawable/action_bar_background</item> </style> 

When I try to include the action bar in another dashboard_activity_layout.xml layout file, as shown below:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" style="@style/CustomTheme" android:id="@+id/activity_dashboard_root_container" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <include layout="@layout/action_bar"/> <LinearLayout android:orientation="vertical" android:id="@+id/fragment_container" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:padding="6dip"> </LinearLayout> </LinearLayout> 

He constantly throws an error:

You must specifiy a valid layout reference. The layout ID @layout/action_bar is not valid. Exception details are logged in Window > Show View > Error Log

I think this is a very simple problem and I am missing a small detail. Any help is appreciated. I adapted this from google input / output code. Is this related to the library project?

+4
source share
4 answers

Despite the fact that the eclipse gave me this error. I was able to run an application that used the library project, and the behavior was expected. I think this has something to do with eclipse.

+2
source

This is apparently a reported ADT error here and here and still exists in ADT R16.

+2
source

@Promod, you opened the linear layout in Action_bar.xml. But you have not added any elements inside the linear layout.

  • Line layout requires minimal parameters such as layout_width, layout_height. Try to add them.
0
source

run eclipse with the -clean option and your problem is fixed. It takes about 30 seconds longer, but

0
source

Source: https://habr.com/ru/post/1380511/


All Articles