In a TabHost, I’m setting up a TabSpec that consists of a header area with a few buttons and below, a ListView. The Activity to manage this TabSpec is defined as “extends ListActivity”.
However, now I’m running into the problem of not being able to define an OnClickListener to check for the submit button pressed. How can I solve that?
Trying to cast the Button by
btnRatingSubmit.setOnClickListener((OnClickListener) this);
raises an ClassCastException…
Here is a basic excerpt of the layout:
<?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>
Instead of
try this: