Reputation: 75
my app crashes when I press a button with android:onClick"toastExpert"
public void toastExpert(){
toastMe(null);
}
public void toastMe(View view) {
CharSequence text = "Hello Myself Dristi!";
int duration = Toast.LENGTH_SHORT;
Toast.makeText(getApplicationContext(), text, duration).show();
}
Anyone please help... The logcat details
Upvotes: 0
Views: 70
Reputation: 586
Your public method toastExpert()
is wrong. You have to add following parameters:
public void toastExpert(View view){
toastMe(null);
}
Note that every method you use in android:onClick
has to look like this
public void yourOnClickMethod(View view){
doSomething();
}
Upvotes: 1
Reputation: 1396
You can go for android:onClick="toastMe" in your button in your xml
Upvotes: 0