मैं जब मैं बढ़ाने के लिएकस्टम रिलेटिव लेआउट को भरते समय क्लास कास्ट अपवाद? 15:
07-22 19 कोशिश इस अपवाद मिल 39.903: त्रुटि/AndroidRuntime (3810): java.lang.ClassCastException: की वजह से android.widget.RelativeLayout
मैं
public class UIBase extends RelativeLayout {}
और एक अधिक विशिष्ट वर्ग: एक आधार वर्ग है
public class Countdown extends UIBase {}
तब मैं बढ़ाने के लिए कोशिश करते हैं और यह अपवाद:
UIBase newView = (UIBase) inflater.inflate(layoutId, parent, true);
यहाँ एक्सएमएल फ़ाइल है:
<?xml version="1.0" encoding="utf-8"?>
<com.Countdown xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/countdown"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/countdownText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="0" />
</com.Countdown>
किसी को भी पता है मैं गलत क्या कर रही हूं?
आपका एक्सएमएल कैसा दिखता है? –
लेआउट फ़ाइल को देखे बिना, और शायद अधिक कोड, आपको सलाह देना मुश्किल है। सुनिश्चित करें कि आपकी लेआउट फ़ाइल में 'UIBase' या 'उलटी गिनती' विजेट है, न कि' RelativeLayout'। – CommonsWare
एक्सएमएल के साथ संपादित। – Joren