Reputation: 3
i want to use the method (findViewById
) but i get an error which i cant solve.
the error is "Type Parameter T has incompatible upperbounds: View and 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);
}
}
Upvotes: 0
Views: 83
Reputation: 1357
you are using RatingBar as your activity name. It's the built-in class in Android. Change name of your Activity and try again
Upvotes: 3
Reputation: 183
declare RatingBar as final (eg. Final RatingBar
or Final TextView
)and see if it can solve the issue
Upvotes: 0
Reputation: 92
Here is Problem : ` got = findViewById(R.id.gotrate); && Also Change Name of Activity becauase it is reserved Word
` it will like this :
public class MyActivity 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 = (RatingBar)findViewById(R.id.gotrate);
}
Upvotes: 0