我想更改列表視圖行的背景,如果列值相同,則列表視圖背景會發生變化,這是我的代碼。如何更改列表視圖中行的背景顏色使用列表視圖列字段
public class FillList extends AsyncTask<String, String, String> {
String z = "";
List<Map<String, String>> prolist = new ArrayList<Map<String, String>>();
@Override
protected void onPreExecute() {
}
@Override
protected void onPostExecute(String r) {
Toast.makeText(getActivity(), r, Toast.LENGTH_SHORT).show();
String[] from = {"C", "D", "E"};
int[] views = {R.id.accname, R.id.openingbalance, R.id.closingblanace};
final SimpleAdapter ADA = new SimpleAdapter(getActivity(),
prolist, R.layout.reportlayout, from,
views);
lstpro.setAdapter(ADA);
}
@Override
protected String doInBackground(String... params) {
try {
Connection con = connectionClass.CONN();
if (con == null) {
z = "Error in connection with SQL server";
} else {
final String stringlevel = getArguments().getString("level");
String query = "select * from GLSCOADetail where AccLevelNo<='"+ stringlevel +"'";
PreparedStatement ps = con.prepareStatement(query);
ResultSet rs = ps.executeQuery();
ArrayList<String> data1 = new ArrayList<String>();
while (rs.next()) {
Map<String, String> datanum = new HashMap<String, String>();
datanum.put("C", rs.getString("AccName"));
datanum.put("D", rs.getString("OpeningBalance"));
datanum.put("E", rs.getString("ClosingBalance"));
prolist.add(datanum);
}
z = "Success";
}
} catch (Exception ex) {
z = ex.getMessage();
}
return z;
}
}
我想改變提交的,如果我的數據庫字段匹配列表視圖,然後排的顏色會改變,請幫助我的數據庫我的列表視圖的背景。
您因而需要自定義列表Adapte: http://stackoverflow.com/questions/8166497/custom-adapter-for-list-view – Sigiria