Если файл макета (activity_main.axml
) не верен, то файл Resource.designer.cs
(который включает в себя сгенерированный идентификатор видов ресурсов, например, идентификатор представления, файл макета и т. Д.) Не может быть сгенерирован правильно.
Мы обнаружили, что в вашем activity_main.axml
1.change
android:orientation = vertical
на
android:orientation = "vertical"
2. когда выдобавьте id к элементу управления, просто добавьте +
, вот так:
android:id="@+id/searchButton"
Not
android:id = "@id/searchButton"
Между тем, убедитесь, что используемые вами изображения существуют в нужном месте. (например, drawable
папка). (android:src ="@drawable/search"
и android:src = "@drawable/add"
)
Примечание :
После того, как мы кодируем, мы можем просто создать приложение, а затембудет иметь несколько журналов ошибок, если у нашего кода есть какие-то проблемы.
Таким образом, весь файл макета выглядит так:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation = "vertical">
<android.support.v7.widget.Toolbar
android:id = "@+id/toolbar1"
android:layout_height = "wrap_content"
android:layout_width = "match_parent"
android:background = "?android:attr/colorPrimary"
android:minHeight = "?android:attr/actionBarSize"
android:theme = "@style/Base.ThemeOverlay.AppCompat.Dark.ActionBar"
android:elevation = "4dp">
<RelativeLayout
android:layout_height = "wrap_content"
android:layout_width = "match_parent">
<TextView
android:layout_centerVertical = "true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text = "Employee"
android:gravity = "center"
android:textStyle = "bold"
android:textColor = "#fff"
android:textSize = "18sp"/>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:id="@+id/searchButton"
android:layout_alignParentLeft = "true"
android:src ="@drawable/search"
android:tint = "#fff"
android:layout_marginLeft = "10dp"/>
<ImageView
android:layout_width="30dp"
android:layout_height="20dp"
android:id="@+id/addButton"
android:layout_alignParentRight = "true"
android:src = "@drawable/add"
android:tint = "#fff"
android:layout_marginLeft = "10dp"/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<EditText
android:visibility = "gone"
android:id = "@+id/searchText"
android:layout_marginLeft = "5dp"
android:layout_marginRight = "5dp"
android:layout_marginBottom = "5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint = "Search"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars = "vertical"
android:background = "#e2e2e2"
android:id = "@+id/myRecyclerView"/>
</LinearLayout>