2
我試圖按字面值的字母順序將此ListView放入列。我已經閱讀過關於這個主題的答案,但還沒有找到任何解決方案。我必須使用Comparable/Comparator嗎?ListView按字母順序無可比較
private ArrayList<HashMap<String, Object>> wordList;
private static final String WORD = "word";
private static final String DEFINITION = "definition";
private static final String NOTES = "notes";
private SimpleAdapter adapter;
ListView listView = (ListView) findViewById(R.id.listView);
final ListView listView2 = (ListView) findViewById(R.id.listView2);
wordList = new ArrayList<>();
HashMap<String, Object> hm;
for (int i = word_counter - 1; i >= 0; i--) {
hm = new HashMap<>();
hm.put(WORD, words[i]);
hm.put(DEFINITION, definitions[i]);
hm.put(NOTES, notes[i]);
wordList.add(hm);
}
adapter = new SimpleAdapter(this, wordList,
R.layout.list_item, new String[]{WORD, DEFINITION, NOTES},
new int[]{R.id.text1, R.id.text2, R.id.text3});
現在它的工作,thanx很多! –
不客氣。 –