Skip to content

Instantly share code, notes, and snippets.

@Rexee
Last active April 25, 2016 15:45
Show Gist options
  • Save Rexee/ce2fda12fd49feaabf90 to your computer and use it in GitHub Desktop.
Save Rexee/ce2fda12fd49feaabf90 to your computer and use it in GitHub Desktop.
SimpleAdapter
String[] texts = {"sometext 1", "sometext 2", "sometext 3"};
ArrayList<Map<String, Object>> data = new ArrayList<Map<String, Object>>(texts.length);
Map<String, Object> m;
for (int i = 0; i < texts.length; i++) {
m = new HashMap<String, Object>();
m.put("TEXT", texts[i]);
data.add(m);
}
String[] from = {"TEXT"};
int[] to = { android.R.id.text1};
SimpleAdapter sAdapter = new SimpleAdapter(this, data, android.R.layout.simple_list_item_1, from, to);
ListView mListView = (ListView) findViewById(R.id.participants);
mListView.setAdapter(sAdapter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment