У меня проблема с добавлением представлений в мой файл axml. Каждый раз, когда я добавляю представление между существующими представлениями, я получаю сообщение об ошибке:
System.InvalidCastException: невозможно преобразовать экземпляр типа "Android.Widget.EditText" в тип "Android.Widget.LinearLayout".
Он пытается преобразовать новый вид в вид, следующий сразу за ним. Нет проблем, когда я добавляю вид в конец страницы. Я могу добавлять представления в другие файлы .axml в рамках проекта без каких-либо проблем. Я не уверен, что я сделал, чтобы сломать это. Кто-нибудь может помочь? Код ниже:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ProgressBar
android:id="@+id/pb_status"
style="?android:attr/progressBarStyle"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/ll_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_margin="@dimen/default_page_margin">
<GridLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:rowCount="1"
android:columnCount="2"
android:minWidth="25px"
android:minHeight="25px"
android:id="@+id/gl_po">
<TextView
android:text="PO #:"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_height="wrap_content"
android:layout_width="225dp"
android:textSize="20sp"
android:textStyle="bold"
android:id="@+id/tv_po_display"
android:layout_weight="1" />
</GridLayout>
<GridLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="2"
android:rowCount="2"
android:minWidth="25px"
android:minHeight="25px">
<TextView
android:text="Part #:"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textStyle="bold"
android:layout_column="0"
android:layout_row="0" />
<TextView
android:layout_height="wrap_content"
android:layout_width="225dp"
android:textSize="20sp"
android:textStyle="bold"
android:id="@+id/tv_part_display"
android:layout_column="1"
android:layout_row="0" />
<TextView
android:text=""
android:layout_height="wrap_content"
android:layout_width="100dp"
android:textSize="20sp"
android:textStyle="bold"
android:layout_column="0"
android:layout_row="1" />
<TextView
android:layout_height="wrap_content"
android:layout_width="225dp"
android:textSize="15dp"
android:id="@+id/tv_part_desc_display"
android:layout_column="1"
android:layout_row="1" />
</GridLayout>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText1" /> <-------DOESN'T LIKE THIS
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp">
<!--Quantity-->
<TextView
android:text="Quantity:"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textStyle="bold"
android:id="@+id/tv_qty" />
<EditText
style="@style/TextEditStyle"
android:background="@drawable/textinputborder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/txt_qty" />
<EditText
style="@style/TextEditStyle"
android:background="@drawable/textinputborder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/txt_vehicle" />
<!--Purity %-->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/ll_purity">
<TextView
android:text="Purity Pct."
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textStyle="bold" />
<EditText
style="@style/TextEditStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/txt_purity"
android:background="@drawable/textinputborder"
android:inputType="numberDecimal"
android:drawableRight="@drawable/pct_sm" />
</LinearLayout>
<!--UOM-->
<TextView
android:text="UOM:"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_uom_dropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/dropdown_background"
android:drawableRight="@drawable/icn_dropdown_open"
android:gravity="center_vertical|left"
android:focusable="true"
android:padding="10dip"
android:textSize="20dp"
android:textColor="@color/dark_text" />
<LinearLayout
android:id="@+id/ll_uom_dropdown_foldout_menu"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dip"
android:background="@drawable/dropdown_background"
android:orientation="vertical"
android:padding="1dip"
android:visibility="gone"
android:focusable="true">
<ListView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lv_uom"
android:choiceMode="singleChoice" />
</LinearLayout>
<!--Location-->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/ll_from_loc"
android:visibility="gone">
<TextView
android:text="From Location:"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_from_loc_dropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/dropdown_background_disabled"
android:drawableRight="@drawable/icn_dropdown_open"
android:gravity="center_vertical|left"
android:focusable="true"
android:padding="10dip"
android:textSize="20dp"
android:textColor="@color/dark_text" />
</LinearLayout>
<TextView
android:id="@+id/tv_to_loc"
android:text="Location:"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_loc_dropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/dropdown_background"
android:drawableRight="@drawable/icn_dropdown_open"
android:gravity="center_vertical|left"
android:focusable="true"
android:padding="10dip"
android:textSize="20dp"
android:textColor="@color/dark_text" />
<LinearLayout
android:id="@+id/ll_loc_dropdown_foldout_menu"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dip"
android:background="@drawable/dropdown_background"
android:orientation="vertical"
android:padding="1dip"
android:visibility="gone"
android:focusable="true">
<ListView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lv_loc"
android:choiceMode="singleChoice" />
</LinearLayout>
<View
android:layout_weight="1"
android:layout_height="0dp"
android:layout_width="match_parent" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp">
<Button
android:id="@+id/btn_submit"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Submit"
style="@style/SM_ButtonStyle" />
<View
style="@style/SM_ButtonSpacer" />
<Button
android:id="@+id/btn_cancel"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Cancel"
style="@style/SM_ButtonStyle" />
<View
style="@style/SM_ButtonSpacer" />
<Button
android:id="@+id/btn_menu"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Menu"
style="@style/SM_ButtonStyle" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
ОБНОВЛЕНИЕ: я получаю сообщение об ошибке, которое заставляет меня проверить ActivityLog.xml. Вот ошибка, которую я вижу оттуда:
System.NullReferenceException: ссылка на объект не установлена для экземпляра объекта. в Xamarin.VisualStudio.Android.Designer.MonoAndroidDesignerService.FindBestAndroidTarget (DesignerProject designerProject, Int32 apiLevel) в E: \ A_work \ 12 \ s \ Xamarin.Designer. Xamarin.VisualStudio.Android.Designer.AxmlTextViewCreationListener.VsTextViewCreated (IVsTextView textViewAdapter) в E: \ A_work \ 12 \ s \ Xamarin.Designer.VisualStudio \ src \ VisualStudio.ers. VisualStudio.Editor. - в Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo (ExceptionceptionObject)