Не могу сослаться на идентификатор Listview (Помощь!) - PullRequest
0 голосов
/ 28 апреля 2020

Я не могу добавить ошибку при просмотре списка, не могу понять, нужна помощь, я пытался изменить идентификатор, но все еще получаю ошибку

 error: <identifier> expected
 ListView list = new (ListView) findViewById(R.id.list);

Моя активность. java

  public class MainActivity extends AppCompatActivity {
        private ListView list;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            ArrayList<String> earth= new ArrayList<>();
            earth.add("d");
            earth.add("d");
            earth.add("d");
            earth.add("f");
            earth.add("d");
            earth.add("f");

                ListView list = new (ListView) findViewById(R.id.list);
            ArrayAdapter<String> adapter= new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,earth);
            list.setAdapter(adapter);
        }
    }

Мой просмотр списка. xml

 <ListView
        android:id="@+id/list"
        android:layout_width="405dp"
        android:layout_height="355dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.014"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.042" />
...