我编写了一个简单的android应用程序,其中一个Activity类实现了SlidingTab接口的OnTriggerListener()回调。我在layout文件夹中的main.xml文件中定义了SlidingTab小部件。代码遵循
<?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">
<!-- (1) incomingCallWidget: the UI displayed while an incoming call is ringing. -->
<com.android.internal.widget.SlidingTab
android:id="@+id/incomingCallWidget"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_alignParentBottom="true"
android:layout_marginBottom="80dip"
/>
</LinearLayout>
Activity类的代码遵循
public class Sliding extends Activity implements SlidingTab.OnTriggerListener{
/** Called when the activity is first created. */
private SlidingTab mIncomingCallWidget;
private static final int IN_CALL_WIDGET_TRANSITION_TIME = 250; // in ms
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.incall_touch_ui);
mIncomingCallWidget = (SlidingTab) findViewById(R.id.incomingCallWidget);
mIncomingCallWidget.setLeftHintText(R.string.slide_to_divert_hint);
mIncomingCallWidget.setRightHintText(R.string.slide_to_accept_hint);
mIncomingCallWidget.setOnTriggerListener((OnTriggerListener) this);
}
现在我在
行获得了ClassCastExceptionmIncomingCallWidget = (SlidingTab) findViewById(R.id.incomingCallWidget);
即。在实例化对象时。
请让我提供有用的信息,我该如何解决这个问题。
答案 0 :(得分:0)
您的代码是指“R.layout.incall_touch_ui”。这将导致Android查看文件“res / layout / incall_touch_ui.xml”,而不是“res / layout / main.xml”。