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.
The cause is your use of a string resource for the method name.
The solution is to get rid of the string resource and to put the method name in the
android:onClick
attribute directly.UPDATE: If the markers do not go away, right-click over the project, and choose Android Tools > Clear Lint Markers.
i had this same problem...
hope this is help full
Soon after update/install it shows errors. But re-running Lint corrects the problem.
Right Click Project -> Android Tools -> Click "Run Lint: Check for common Errors"