Reputation: 13452
The (Floating action button) works but when I try to set it as a button it crashes the app?
Button MyButton = (Button) findViewById(R.id.fab);
MyButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
}
});
The above crashes the app, but when I remove it everything is fine? Any ideas?
https://github.com/makovkastar/FloatingActionButton
Upvotes: 0
Views: 825
Reputation: 17734
The FloatingActionButton from this library extends ImageView which extends View:
It is not a subclass of the Android Button. Cast instead to FloatingActionButton:
FloatingActionButton myButton = (FloatingActionButton) findViewById(R.id.fab);
Upvotes: 4