在一个TabHost中,我设置了一个TabSpec,它包含一个带有几个按钮和下面的一个ListView的标题区域。管理此TabSpec的活动被定义为“扩展ListActivity”。 但是,现在我遇到了无法定义OnClickListener来检查按下提交按钮的问题。我该如何解决这个问题?TabSpec与ListActivity ...如何设置Button的OnClickListener?
试图通过
btnRatingSubmit.setOnClickListener((OnClickListener) this);
引发一个ClassCastException异常铸按钮...
这里是布局的基本摘录:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RatingBar
android:id="@+id/ratingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/edComment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine" >
</EditText>
<Button
android:id="@+id/btnSubmit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/btnSubmit" />
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
谢谢 - 此解决方案为我工作! – richey