Hi This is my code..
....
public void QuerySQL(String SQL) {
try {
Statement statement = connect.createStatement();
rs = statement.executeQuery(SQL);
List<Map<String, String>> data = null;
data = new ArrayList<Map<String,String>>();
while(rs.next()) {
Map<String, String> datanum = new HashMap<String, String>();
datanum.put("A", rs.getString("RoomNumber"));
datanum.put("B", rs.getString("RoomStatus"));
datanum.put("C", rs.getString("RoomType"));
data.add(datanum);
}
String[] from = {"A","B","C"};
int[] views = {R.id.txt_number,R.id.status,R.id.txt_type};
ADAhere = new SimpleAdapter(this, data, R.layout.layout_list_item, from, views);
listViewStats.setAdapter(ADAhere);
} catch (Exception e) {
Toast.makeText(Main.this, e.getMessage().toString(),Toast.LENGTH_LONG).show();
}
}
....
This is an android project that get a string from the sql server database. All of things already working properly. The thing is I want to put the Image instead of string. And the Image is already in the drawable hdpi project folder.
For example the "RoomStatus" in database have 4 types. Clean, Dirty, Occupied, Closed. I need to get the picture from the drawable hdpi R.drawable.clean, R.drawable.dirty, R.drawable.occupied, R.drawable.closed. But I dont get the idea how to put the picture based on the string get from the database. Any help I'll really appreciate. Thx in advance