2014-01-16 4 views
1

footer를 userdata에 연결하려고하는데 응용 프로그램이 충돌합니다. 아무도 이것으로 도울 수 있습니까?두 개의 레이아웃 연결

로그인 클래스 :

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); 
    } 
} 

전체 이름, 휴대폰 번호, 직업 버튼, 저장 메인 레이아웃과 이미지 뷰의 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 
+0

메인 layout.xml을 게시하십시오. –

+0

@MD 레이아웃이 추가되었습니다. – addy123

+0

충돌의 스택 추적을 가져올 수 있습니까? – OrhanC1

답변

0

로그 고양이이 시도 ..

XML을

아래

<include 
    android:id="@+id/footer_lay" 
    layout="@layout/footer" /> 
같은 레이아웃 ID를 포함로 footer_lay를 타고

자바

그리고 당신의 글이 대체 코드 아래

RelativeLayout footer_lay = (RelativeLayout) findViewById(R.id.footer_lay); 

ad1= (ImageView) footer_lay.findViewById(R.id.ad1); 
ad2= (ImageView) footer_lay.findViewById(R.id.ad2); 
ad3= (ImageView) footer_lay.findViewById(R.id.ad3); 
ad4= (ImageView) footer_lay.findViewById(R.id.ad4); 
ad5= (ImageView) footer_lay.findViewById(R.id.ad5); 
ad6= (ImageView) footer_lay.findViewById(R.id.ad6); 
horizontalScrollView1=(HorizontalScrollView) footer_lay.findViewById(R.id.horizontalScrollView1); 
+0

그것도 여전히 충돌 .. – addy123

+0

@AdvitiyaAbrol 게시 그 logcat 오류. – Hariharan

+0

로그 고양이는 여기에 게시되지 않습니다. 거대한 – addy123

0

처럼 footer_lay.findViewById(R.id.ad1);ImageView을 누워 LinearLayout 및보기로 footer_lay 참조 :

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); 

로 :

01,234,333,684,643,411,
1

당신은 여기에 잘못 :

horizontalScrollView1 = (HorizontalScrollView) horizontalScrollView1 
      .findViewById(R.id.horizontalScrollView1); 

아래로 이것을 대체 :

horizontalScrollView1 = (HorizontalScrollView)findViewById(R.id.horizontalScrollView1); 

이보십시오.

관련 문제