“ArrayAdapter requires the resource ID to be a TextView” xml problems

前端 未结 3 1295
生来不讨喜
生来不讨喜 2020-11-22 01:45

I am getting an error when trying to set my view to display the ListView for the file I want to display(text file). I am pretty sure it has something to do with

3条回答
  •  遥遥无期
    2020-11-22 02:19

    Soution is here

    listitem.xml

    
    
    
         
         
    
    

    Java code :

     String[] countryArray = {"India", "Pakistan", "USA", "UK"};
     ArrayAdapter adapter = new ArrayAdapter(this, R.layout.listitem,R.id.textview, countryArray);
     ListView listView = (ListView) findViewById(R.id.listview);
     listView.setAdapter(adapter);
    

提交回复
热议问题