0
次のカスタムアダプタを使用して、DBカーソルからMyリストコントロールを作成しています。 スーパーが呼び出されたときに、特にこのコードがコンストラクターでクラッシュする理由を理解できません。DBカーソル付きのカスタムアダプタのクエリ
public class ListAdaptor extends SimpleCursorAdapter {
private Cursor dataCursor;
private LayoutInflater mInflater;
class ViewHolder {
public TextView label = null;
public CheckBox chkBx = null;
public TextView price = null;
public TextView weight = null;
}
//constructor
public ListAdaptor(Context context, int layout, Cursor dataCursor, String[] from, int[] to) {
super(context, layout, dataCursor, from, to);
this.dataCursor = dataCursor;
mInflater = LayoutInflater.from(context);
}
public View getView(int position, View convertView, ViewGroup parent) {
// A ViewHolder keeps references to children views to avoid unneccessary calls
// to findViewById() on each row.
ViewHolder holder;
// When convertView is not null, we can reuse it directly, there is no need
// to reinflate it. We only inflate a new View when the convertView supplied
// by ListView is null.
if (convertView == null) {
// Inflate the view
convertView = mInflater.inflate(R.layout.listviewlyt, null);
// Get the ID's of the views
TextView tmpLbl = (TextView)convertView.findViewById(R.id.label);
CheckBox tmpChkBx = (CheckBox)convertView.findViewById(R.id.chkbox);
TextView tmpPrc = (TextView)convertView.findViewById(R.id.labelPrice);
TextView tmpWt = (TextView)convertView.findViewById(R.id.labelWt);
// Creates a ViewHolder and store references to the two children views
// we want to bind data to.
holder = new ViewHolder();
holder.label = tmpLbl;
holder.chkBx = tmpChkBx;
holder.price = tmpPrc;
holder.weight = tmpWt;
// Set the Tag
convertView.setTag(holder);
}
else {
// Get the ViewHolder back to get fast access to the TextView
// and the ImageView.
holder = (ViewHolder) convertView.getTag();
}
// Bind the data efficiently with the holder.
// Cursor to current item
dataCursor.moveToPosition(position);
String keyWrd = dataCursor.getString(2);
String price = dataCursor.getString(3);
TextView labelRef = holder.label;
CheckBox chbxRef = holder.chkBx;
TextView labelPrc = holder.price;
TextView labelWt = holder.weight;
labelRef.setText(keyWrd);
labelPrc.setText(price);
//chbxRef.setChecked(refObj.flag);
//labelWt.setText(refObj.wt);
return convertView;
}
}
誰かが理由を見つけるのを手助けできますか?
ポスト・エラー・ログをしてください与える可能性があります。 – hovanessyan
スレッド【<3>メイン](サスペンド)\t \t \t \t ActivityThread.performLaunchActivity(ActivityThread $ ActivityRecord、インテント)ライン:2494 \t \t \t \t ActivityThread.handleLaunchActivity(ActivityThread $ ActivityRecord、インテント)ライン:2512 \t \t \t \t ActivityThread.access $ 2200(ActivityThread、ActivityThread $ ActivityRecord、Intent)行:119 \t \t \t \t ActivityThread $ H.handleMessage(メッセージ)行:1863 \t \t \t \t ActivityThread $ H(ハンドラ).dispatchMessage(メッセージ)ライン:99 \t \t \t \t Looper.loop()行:123 \t \t \t \t ActivityThread.main(文字列[])ライン:4363 – Phoenix
何例外ですか? –