my code is about a listview with sub item, I fill it with array string[] but only show me the first string, someone can I help me?
private String[] d1 = new String[5];
private String[] d2 = new String[5];
ArrayList<HashMap<String, String>> data;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listview);
listView = (ListView) findViewById(R.id.list);
for(int i=0;i<lengh;i++){
Map<String,Object> daat = new HashMap<String, Object>();
daat.put("title", d1[i]);
daat.put("sub", d2[i]);
data.add(daat);
}
SimpleAdapter adapter = new SimpleAdapter(this, data, android.R.layout.simple_list_item_2,
new String[]{"title", "sub"}, new int[]{android.R.id.text1, android.R.id.text2});
listView.setAdapter(adapter);
adapter.notifyDataSetChanged();
for(int i=0;i<d1.length;i++){
Map<String,Object> daat = new HashMap<String, Object>();
daat.put("title", d1[i]);
daat.put("sub", d2[i]);
data.add(daat);
}
hear in for loop specify which string length and try i hope it work .