Type parameter t has incompatible upper bounds view and listview

Viewed 606

I have the error when I initialize the list view findViewById(R.id.listview)

error: incompatible types: no unique maximal instance exists for type variable T with upper bounds ListView,View where T is a type-variable: T extends View declared in method findViewById(int)

public class ListView extends AppCompatActivity {
    ListView listview;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list_view);

        listview = findViewById(R.id.listview);

    }
}
1 Answers

Rename your activity name to ListView to ListViewActivity.

Because when you are declaring ListView listview; listview becomes Activity type.

Related