所以我想更改一个布局。所以我给它添加了一个线性布局,并以某种方式崩溃了与它无关的代码。所以我在这里发布一些代码。在布局中添加事物会导致崩溃
这是我的主要文件和发生崩溃的病态点。 保护覆盖无效的OnCreate(束束) {
base.OnCreate(bundle);
SetContentView(Resource.Layout.layoutLogin);
gbtnSignUp = FindViewById<Button>(Resource.Id.btnSignUp);
gbtnSignIn = FindViewById<Button>(Resource.Id.btnSignIn);
gbtnSignUp.Click += gbtnSignUp_Click;
gbtnSignIn.Click += gbtnSignIn_Click; // here is where it crashes
}
现在我的布局。 Ill指出我添加哪个部分会增加崩溃。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:weightSum="100"
android:layout_height="fill_parent">
<ListView
android:layout_weight="80"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@drawable/ListViewHighlight"
android:id="@+id/companyListView" />
<ProgressBar
android:layout_weight="10"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@drawable/ListViewHighlight"
android:id="@+id/progressBar1" />
<LinearLayout// just from this linear layout existing it causes a crash
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="10"
android:weightSum="100"
android:id="@+id/linearLayout1">
<TextView
android:text="Text"
android:layout_width="0dp"
android:layout_weight="10"
android:layout_height="match_parent"
android:id="@+id/textView1" />
<ImageButton
android:src="@drawable/defaultAdd"
android:layout_width="0dp"
android:layout_weight="90"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:id="@+id/imageButton1" />
</LinearLayout>
</LinearLayout>
这种布局还没有链接到导致崩溃的视图。哎呀我甚至从项目中删除了对这个视图的所有引用,它仍然崩溃。
这里是错误信息强制我在我指定的行中断开。
System.NullReferenceException:对象不设置到对象的实例
我也可以发表评论这一行了,但ITLL使其能够运行,但不适依然能够按下按钮,然后做一些非常棒的行为,我不应该按它开始。
XML登录按钮的
<Button
android:text="Sign In"
android:layout_width="match_parent"
android:layout_weight="15"
android:layout_height="0dp"
android:id="@+id/btnSignIn"
android:textSize="25sp"
android:background="@drawable/ButtonSignInStyle"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp" />
在阅读代码让它通过的线性布局后,现在没有了。现在,如果我在线性布局 – TheMangaStand