displaying a string on the textview when clicking a button in android

后端 未结 9 2028
情深已故
情深已故 2020-12-10 08:43

I\'m very new to Android development and just started to study.

What I\'m trying is to add a button and when that button is pressed a text \"my first project\" to ge

9条回答
  •  情话喂你
    2020-12-10 09:14

    This is because you DON'T associated the OnClickListener() on the button retrieve from the XML layout.

    You don't need to create object because they are already created by the Android system when you inflate XML file (with the Activity.setContentLayout( int resourceLayoutId ) method).

    Just retrieve them with the findViewById(...) method.

提交回复
热议问题