2009-08-25 6 views
5

जब मैं परिदृश्य मोड में स्विच, निम्नलिखित कस्टम दृश्य एंड्रॉयड 1.5r3 कप केक में एक अपवाद फेंकता है:ग़लत स्थिति वर्ग - कस्टम दृश्य के साथ एंड्रॉयड 1.5 में उम्मीद कर देखें राज्य अपवाद

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

कोई विचार क्या हो रहा है?

उत्तर

6

आह, मूल रूप से बताए गए समस्या का निदान करना मुश्किल होगा।

बाहर कर देता है अपने कस्टम के अंदर देखने कि मेरे ProgressBar @+id/progress नामित किया गया था, लेकिन मैं यह भी TextProgressBar @+id/progress कहा जाता है जब मैं अपने लेआउट में कस्टम दृश्य TextProgressBar इस्तेमाल किया, एक ही आईडी वाले दो दृश्य में जिसके परिणामस्वरूप।

उनमें से एक का नाम बदलने से समस्या ठीक हो गई।

+0

मैन हाँ ... ट्रैक करना मुश्किल है। –

+0

वाह, आपने मुझे इस चीज़ पर घंटों खर्च करने से बचाया, thx! – Maragues

+0

यह मेरा भी गलत था ... युक्ति: हाइराची दर्शक इसे आसानी से दृश्यमान बनाता है –

संबंधित मुद्दे