问题描述
您可以在下面找到我的布局代码
我在 Visual Studio 中看到以下错误
Severity Code Description Project File Line Suppression State Error Within a layout,id's should be unique since otherwise "FindViewById<T> (Int32)" can return an unexpected view. TestApp
Duplicate "@id/linearLayout1 @id/linearLayout6 @id/textView1,already defined in this layout
我什至没有任何 id textView1
我试图清理项目,但没有帮助。我在这里遗漏了什么吗?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/linearLayout1" >
<Toolbar
android:minHeight="?android:attr/actionBarSize"
android:background="?attr/colorPrimary"
android:minWidth="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/toolbar1" />
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout6" >
<TextView
android:text="Smart app"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/smName" />
<TextView
android:text="1.0.0v"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:id="@+id/appVersion" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout5" >
<TextView
android:text="S/N 01234"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/serialNumber" />
<TextView
android:text="21.01.2012 13:15"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:id="@+id/date" />
</LinearLayout>
<Space
android:layout_width="match_parent"
android:layout_height="20dp"
android:id="@+id/space1" />
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout4" >
<TextView
android:text="logowanie"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/login" />
</LinearLayout>
<Space
android:layout_width="match_parent"
android:layout_height="20dp"
android:id="@+id/space2" />
<TableLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="*"
android:id="@+id/gridLayout1" >
<TableRow
android:id="@+id/row1"
android:layout_width="fill_parent"
android:layout_height="0dp">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Login"
android:layout_columnWeight="1"
android:id="@+id/editPassword" />
</TableRow>
<TableRow
android:id="@+id/row2"
android:layout_width="fill_parent"
android:layout_height="0dp">
<EditText
android:inputType="textPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Hasło"
android:id="@+id/editLogin" />
</TableRow>
</TableLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout2" >
<Button
android:text="Zaloguj"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/loginButton" />
<Button
android:text="Wyjdź"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/cancelButton" />
</LinearLayout>
</LinearLayout>
解决方法
重新启动和重建项目有帮助,看起来像视觉工作室故障