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

后端 未结 9 2020
情深已故
情深已故 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:08

    Just check your code in .java class

    You had written below line

     mybtn.setOnClickListener(this);
    

    before initializing the mybtn object I mean

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

    just switch this two line or put that line "mybtn.setOnClickListener(this)" after initializing your mybtn object and you will get the answer what you want..

提交回复
热议问题