So although I am not new to programming (I have been developing for iOS for about 6 months not) I have just started to learn Android development and wanted to make the simplest app ever ` @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
Button buckysButton = (Button)findViewById(R.id.buckysButton);
buckysButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View vw) {
TextView buckysText = (TextView)findViewById(R.id.buckysText);
if (buckysText.getText().toString() == "Hello") buckysText.setText("World!");
else if (buckysText.getText().toString() == "World!") buckysText.setText("Hello");
}
});
}`
I get no errors. However, nothing happens when I press the button. Nothing changes, and yes, I am positive that my tables original text is set to 'Hello' because this is what I have my label set to in strings.xml. <string name="message_text">Hello</string>
Aucun commentaire:
Enregistrer un commentaire