我試圖用戶數據連接頁腳,但應用程序崩潰。有人能幫忙嗎?連接兩個佈局
登錄類:
public class Login extends Activity {
EditText fullname, mobilenumber, occupation;
Button save;
ImageView ad1, ad2, ad3, ad4, ad5, ad6;
HorizontalScrollView horizontalScrollView1;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.userdata);
fullname = (EditText) findViewById(R.id.fullname);
mobilenumber = (EditText) findViewById(R.id.mobile);
occupation = (EditText) findViewById(R.id.occupation);
save = (Button) findViewById(R.id.btnSave);
ad1 = (ImageView) ad1.findViewById(R.id.ad1);
ad2 = (ImageView) ad2.findViewById(R.id.ad2);
ad3 = (ImageView) ad3.findViewById(R.id.ad3);
ad4 = (ImageView) ad4.findViewById(R.id.ad4);
ad5 = (ImageView) ad5.findViewById(R.id.ad5);
ad6 = (ImageView) ad6.findViewById(R.id.ad6);
horizontalScrollView1 = (HorizontalScrollView) horizontalScrollView1
.findViewById(R.id.horizontalScrollView1);
}
}
全名,移動電話號碼,職業按鈕來保存,這些從主要佈局和ImageView的AD1,AD2,AD3,AD4,AD5,AD6; horizontalScrollView1,這些來自footerlayout。 我從主佈局調用footer.layout。像這樣:
<include layout="@layout/footer" />
頁腳佈局從主佈局可見,但應用程序崩潰。不知道爲什麼!
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="10dip" >
<!-- Full Name Label -->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Full Name"
android:textColor="#372c24"
tools:ignore="HardcodedText" />
<EditText
android:id="@+id/fullname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:layout_marginTop="5dip"
android:singleLine="true" />
<!-- Email Label -->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Mobile number"
android:textColor="#372c24"
tools:ignore="HardcodedText" />
<EditText
android:id="@+id/mobile"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:layout_marginTop="5dip"
android:singleLine="true"
android:inputType="phone" />
<!-- Password Label -->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Occupation"
android:textColor="#372c24"
tools:ignore="HardcodedText" />
<EditText
android:id="@+id/occupation"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:singleLine="true"
tools:ignore="TextFields" />
<!-- Register Button -->
<Button
android:id="@+id/btnSave"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dip"
android:text="Save"
tools:ignore="HardcodedText" />
<include layout="@layout/footer" /> </LinearLayout><!-- Registration Form Ends -->
日誌貓
01-16 15:48:54.048: E/AndroidRuntime(9072): Uncaught handler: thread main exiting due to uncaught exception
01-16 15:48:54.058: E/AndroidRuntime(9072): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mixorg.parsefooter/com.mixorg.parsefooter.Login}: java.lang.ClassCastException: android.widget.RelativeLayout
01-16 15:48:54.058: E/AndroidRuntime(9072): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2503)
01-16 15:48:54.058: E/AndroidRuntime(9072): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
01-16 15:48:54.058: E/AndroidRuntime(9072): at android.app.ActivityThread.access$2200(ActivityThread.java:123)
01-16 15:48:54.058: E/AndroidRuntime(9072): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
01-16 15:48:54.058: E/AndroidRuntime(9072): at android.os.Handler.dispatchMessage(Handler.java:99)
01-16 15:48:54.058: E/AndroidRuntime(9072): at android.os.Looper.loop(Looper.java:123)
01-16 15:48:54.058: E/AndroidRuntime(9072): at android.app.ActivityThread.main(ActivityThread.java:4370)
01-16 15:48:54.058: E/AndroidRuntime(9072): at java.lang.reflect.Method.invokeNative(Native Method)
01-16 15:48:54.058: E/AndroidRuntime(9072): at java.lang.reflect.Method.invoke(Method.java:521)
01-16 15:48:54.058: E/AndroidRuntime(9072): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-16 15:48:54.058: E/AndroidRuntime(9072): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-16 15:48:54.058: E/AndroidRuntime(9072): at dalvik.system.NativeStart.main(Native Method)
01-16 15:48:54.058: E/AndroidRuntime(9072): Caused by: java.lang.ClassCastException: android.widget.RelativeLayout
01-16 15:48:54.058: E/AndroidRuntime(9072): at com.mixorg.parsefooter.Login.onCreate(Login.java:22)
01-16 15:48:54.058: E/AndroidRuntime(9072): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-16 15:48:54.058: E/AndroidRuntime(9072): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2466)
01-16 15:48:54.058: E/AndroidRuntime(9072): ... 11 more
01-16 15:48:54.088: E/SemcCheckin(9072): Get crash dump level : java.io.FileNotFoundException: /data/semc-checkin/crashdump
發佈您的主layout.xml –
@MD佈局添加 – addy123
我們可以得到你的崩潰的堆棧跟蹤? – OrhanC1