Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build a Simple Android App (2014) Basic Android Programming Making a Button Do Something

Cassandra Gugoff
Cassandra Gugoff
600 Points

Hello! I have entered the same exact thing that the video shows and am getting an error message of "Inconvertible types"

It says showFactButton never used

What have you tried so far? (Post your code so i can help) and what are you trying to achieve ?

Cassandra Gugoff
Cassandra Gugoff
600 Points

Button showFactButton = (Button) findViewById(R.id.showFactButton);

Does this look right?

1 Answer

Your code looks correct however you're doing little errors, you have:

Button showFactButton = (Button) findViewById(R.id.showFactButton);

Really, you should have:

Button newFactButton = (Button) findViewById(R.id.showFactButton);

The reason why you're getting an error is simply because you're naming your new button "showFactButton" and then your trying to find the view by id called 'showFactButton" so in other words, you're basically setting the name of the button the same as the name of a button you're looking for as 'showFactButton' already exists so you shouldn't be trying to create a new one.

Hope this helps