Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
230 views
in Technique[技术] by (71.8m points)

android - 使用findViewById()时出现错误(i'm getting an error while using findViewById())

i want to use the method ( findViewById ) but i get an error which i cant solve.

(我想使用方法( findViewById ),但出现错误,无法解决。)

the error is "Type Parameter T has incompatible upperbounds: View and RatingBar".

(错误是“类型参数T具有不兼容的上限:视图和RatingBar”。)

For fixing this i tried closing the activity and opening another one but it didn't work.

(为了解决这个问题,我尝试关闭活动并打开另一个活动,但没有成功。)

public class RatingBar extends AppCompatActivity {

    RatingBar got , bd;
    TextView gottxt , bdtxt;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rating_bar);

        init()
    }

    private void init(){
        got = findViewById(R.id.gotrate);
    }
}
  ask by iliya translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

you are using RatingBar as your activity name.

(您正在使用RatingBar作为您的活动名称。)

It's the built-in class in Android.

(这是Android中的内置类。)

Change name of your Activity and try again

(更改活动名称,然后重试)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...