の情報を表示しようとしてCursor
います。ListView
各行にはとが含まれてImageView
いTextView
ます。私はCustomCursorAdapter
拡張機能を持っています。カーソルからのデータを評価しCursorAdapter
、bindView
それに基づいてビューの画像とテキストを設定します。
アプリを実行するとListView
、正しい行数が表示されますが、空です。bindViewをオーバーライドするときに何かを見逃したことは知っていますが、何がわからないのです。
どんな助けでも大歓迎です。
private class CustomCursorAdapter extends CursorAdapter {
public CustomCursorAdapter() {
super(Lmw.this, monitorsCursor);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
LayoutInflater layoutInflater = getLayoutInflater();
return layoutInflater.inflate(R.layout.row, null);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
try {
int monitorNameIndex = cursor.getColumnIndexOrThrow(DbAdapter.MONITORS_COLUMN_MONITOR_NAME);
int resultTotalResponseTimeIndex = cursor.getColumnIndexOrThrow(DbAdapter.RESULTS_COLUMN_TOTAL_RESPONSE_TIME);
String monitorName = cursor.getString(monitorNameIndex);
int warningThreshold = cursor.getInt(resultTotalResponseTimeIndex);
String lbl = monitorName + "\n" + Integer.toString(warningThreshold) + " ms";
TextView label = (TextView) view.findViewById(R.id.label);
label.setText(lbl);
ImageView icon = (ImageView)view.findViewById(R.id.icon);
if(warningThreshold < 1000) {
icon.setImageResource(R.drawable.ok);
} else {
icon.setImageResource(R.drawable.alarm);
}
} catch (IllegalArgumentException e) {
// TODO: handle exception
}
}
}