잘못된 상태 클래스 - 사용자 지정보기가 포함 된 Android 1.5의 상태 예외 기대

StackOverflow https://stackoverflow.com/questions/1325576

  •  19-09-2019
  •  | 
  •  

문제

조경 모드로 전환하면 다음 사용자 정의보기는 Android 1.5R3 Cupcake에서 예외를 던집니다.

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.opentable/com.opentable.activity.SearchResults}: 
    java.lang.IllegalArgumentException: Wrong state class -- expecting View State

내 코드 :

public class TextProgressBar extends LinearLayout {
    public TextProgressBar(Context context, AttributeSet attrs) {
        super(context, attrs);
        ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.text_progress_bar, this, true);
        setGravity(Gravity.CENTER);
    }

    public TextProgressBar(Context context) {
        this(context,null);
    }
}

이보기의 XML은 매우 간단합니다.

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:indeterminate="true"
        android:id="@+id/progress" />

    <TextView
        android:text="Loading..."
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>

무슨 일이 일어나고 있는지 아이디어가 있습니까?

도움이 되었습니까?

해결책

아, 문제는 원래 언급 된대로 진단하기가 어려웠을 것입니다.

내 커스텀 뷰 내부에서 내 ProgressBar가 지명되었음을 알 수 있습니다. @+id/progress,하지만 내 레이아웃에서 사용자 정의보기 텍스트 프로그램을 사용했을 때도 TextProgressbar도 불렀습니다. @+id/progress, 동일한 ID로 두 개의 뷰가 발생합니다.

그들 중 하나를 바꾸면 문제가 해결되었습니다.

다른 팁

나는 조각과 함께 ViewPager를 사용하고있었습니다. 먼저, ViewPager를 위해 각 조각을 테스트하여 실제로 오류가 발생한 위치를 확인했습니다. 마지막으로, 나는 같은 이름의 레이아웃의 ID를 사용하고 있음을 알아 냈습니다. 그런 다음보기의 ID를 변경했습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top