我有以下代码,当我单击每一行时,它没有注册 onclick 事件并且没有显示日志。
我可能正在做一些愚蠢的事情,所以任何帮助都将不胜感激。
public void loadTable(){
File dbfile = new File(Global.currentDBfull);
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbfile, null);
mItemName.clear();
mItemID.clear();
adapter.notifyDataSetChanged();
String SQLStatement = "select * from assets where areaobjectid = '" + StationObjectID + "' and CriticalAsset = 'Y'";
Log.e("SQLSTATEMENT", SQLStatement);
String intCount = "0";
Cursor c = db.rawQuery(SQLStatement, null);
if(c.getCount() != 0) {
c.moveToFirst();
while(!c.isAfterLast()) {
mItemName.add(c.getString(c.getColumnIndex("Description")));
mArrayClick.add(c.getString(c.getColumnIndex("StationObjectID")));
mItemStatus.add(c.getString(c.getColumnIndex("ConditionID")));
Log.e("MITEMSTATUS",c.getString(c.getColumnIndex("ConditionID")));
c.moveToNext();
}
rowCount = mItemName.size();
listView = (ListView) findViewById(R.id.lvAssets);
adapter.notifyDataSetChanged();
int[] colors = {0, 0xFFFF0000, 0};
listView.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors));
listView.setDividerHeight(1);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
Log.e("TOMTEST", "Clicked");
}
});
} else {
Log.e("Assessment", "No Results");
}
db.close();
}
class CustomAdapter extends BaseAdapter
{
@Override
public int getCount() {
return mItemName.size();
}
@Override
public Object getItem(int arg0) {
return null;
}
@Override
public long getItemId(int arg0) {
return 0;
}
@Override
public View getView(int arg0, View arg1, ViewGroup arg2) {
ImageButton btnAction;
LayoutInflater inf=getLayoutInflater();
View v=inf.inflate(R.layout.iconrow, arg2,false);
ImageView ivStatus=(ImageView)v.findViewById(R.id.icon);
TextView tv=(TextView)v.findViewById(R.id.text);
btnAction = (ImageButton)v.findViewById(R.id.btnAction);
final String itemID = "Item ID";
final String itemText = "Item Text";
final String itemStage = "Item Strage";
tv.setText(mItemName.get(arg0).toString());
String currentStatus = mItemStatus.get(arg0).toString();
if(Functions.isNullOrEmpty(mItemStatus.get(arg0).toString())){
ivStatus.setImageResource(R.drawable.ico_not_verified);
} else if(mItemStatus.get(arg0).toString() == "99") {
ivStatus.setImageResource(R.drawable.ico_not_found);
} else {
ivStatus.setImageResource(R.drawable.ico_found);
}
return v;
}
}