我想顯示10元/我有我的Java文件中的字符串時,ArrayList
:如何使一個ArrayAdapter(機器人工作室)
ArrayList<String[]>Numbers = new ArrayList<String[]>();
String[] ListOfNumbers = new String[10];
ListOfNumbers[0] = "One";
ListOfNumbers[1] = "Two";
ListOfNumbers[2] = "Three";
ListOfNumbers[3] = "Four";
ListOfNumbers[4] = "Five";
ListOfNumbers[5] = "Six";
ListOfNumbers[6] = "Seven";
ListOfNumbers[7] = "Eight";
ListOfNumbers[8] = "Nine";
ListOfNumbers[9] = "Ten";
而且我想,以顯示所有這些佈局。
UPDATE: 我說,在java文件,這一點:
ListView _list = (ListView) findViewById(R.id._list);
ArrayAdapter<String> adapter = new ArrayAdapter<>(getApplicationContext(), android.R.layout.simple_list_item_1 , ListOfNumbers);
_list.setAdapter(adapter);
並且XML:
<ListView
android:id="@+id/_list"
android:layout_height="wrap_content"
android:layout_width="match_parent">
</ListView>
但現在,我運行模擬器,它崩潰。
檢查:http://www.vogella.com/tutorials/AndroidListView/article.html – Sayem
這個問題似乎是題外話,因爲OP沒有做對參數的最起碼的研究。 –
前段時間我試過那個,但我不明白。 –