I updated Android SDK Tools to revision 17 and after I opened Eclipse I found a list of new errors in the 'Problems' view which weren't there before the update. These errors were in XML Layout files where I had defined the onClick attribute for buttons. On mouse-over the error message example:
"Corresponding method handler 'public void @string/timespanDefinition_btnSave_Click(android.view.View)' not found"
returned. I have already defined the corresponding method handler and the string representation for this event name. What is the cause and solution of this problem?
Some code:
XML Layout
<ToggleButton
android:id="@+id/timespanDefinition_tglVibration"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="true"
android:onClick="@string/timespanDefinition_tglVibration_Click"
android:saveEnabled="true" />
Activity which inflates XML Layout
public class TimespanDefinitionActivity extends Activity
{
// -- Attributes -- //
private long mRowId = -1;
private StringBuilder mBitWeekDays;
private String mTitle;
private EditText txtTitle;
private TabHost tabHost;
private TimePicker tmepkrStart;
private TimePicker tmepkrEnd;
private CheckBox[] weekDays;
private SeekBar skbrVolume;
private ToggleButton tglVibration;
// -- Class Events -- //
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.timespan_definition);
initializeResources();
Bundle extras = getIntent().getExtras();
// Get the time-span Row ID
mRowId = (extras != null) ? extras.getLong(RVSUtilities.getDefaultPackage() + TimespanScheduleTable.KEY_ROWID)
: -1;
populateResources();
}
// -- User Events -- //
public void tglVibration_Click(View v)
{
if (((ToggleButton) v).isChecked())
{
Vibrator vibrate = (Vibrator) getSystemService(VIBRATOR_SERVICE);
vibrate.vibrate(1000);
}
}
strings.xml:
<string name="timespanDefinition_tglVibration_Click">tglVibration_Click</string>
Note: The app is targeting Android 2.3.3 specifically Google API version 10
Thank you.
android:onClick="tglVibration_Click"
but was all in vein because the error remained. However it seems like the error didn't update with the new attribute value. I therefore cleaned and rebuild the project and even tried closing and re-opening Eclipse but the error remained the same: "Corresponding method handler 'public void @string/timespanDefinition_tglVibration_Click(android.view.View)' not found" Any ideas? – Footmark