I have some code that when I run it returns a null pointer error. This is the code and error from the logcat:
import android.support.v7.app.AppCompatActivity;
im
Try to change the theme and check if it works.
android:theme="@android:style/Theme.Holo.Light"
The problem is this line:
!textViewString.equals()
Because you've not given the value to the textViewString
anywhere before using it. Assign it to an empty string at least, or simply delete that line since at the moment it's not doing you much good, I don't really get it's point. Since you're nowhere changing it's value, none of your buttons will work (even without the exception).
You are not setting the onClickListener for your red button, you are reassigning the listener to the blue button.
Button red = (Button) findViewById(R.id.red_button);
blue.setOnClickListener(new View.OnClickListener() {
Have you also defined the onClick property in the xml layout file? If so then you need to ensure you have a method matching the name you have specified. For example if you have entered
onClick="buttonClicked"
You need to define a method called
public void buttonClicked() { /* OnClick functionality here */ }
See: @https://stackoverflow.com/a/38547338/1540698 from @vucko for your second issue.
In your Layout, you say:
android:onClick="onClick"
It appears that you did not include all of the code for the Activity but I'd bet that it does not define a method named onClick
All you need to do is define the method.