Cannot convert from View to Button

后端 未结 3 976
一个人的身影
一个人的身影 2021-01-28 06:29

Very frustrating problem I have here. I have this code:

Button b = findViewById(android.R.id.button1);

And I\'m getting this error on it:

3条回答
  •  天涯浪人
    2021-01-28 06:53

    remove android.R from packages and import your R.

    import com.companyname.productname.R;
    

    and change also button refrence

    Button b = (Button)findViewById(R.id.button1);
                                    ^^^^^^^^^^^^
    

提交回复
热议问题