我正在使用下面的代码进行 listview click 。但这对我不起作用
public class ApparelsSubcatBrand extends ListActivity{
int position_list_v;
//ListAdapter adapter;
String urlImg, pid, pname, mrp, shipping, sellinprice = null, prodSize,
selSize,cbValue;
ListView listView1;
protected SQLiteDatabase sqlitedatabase_obj;
Cursor cursor;
public static String[] title_array ;
public static String[] description_array ;
protected ListAdapter adapter;
SQLiteDatabase dh;
String[] product_name = {};
int[] to_for_text_in_list = {R.id.title_info_txt_v};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.apparels_subcat_brand);
AndroidContext.setContext(this);
sqlitedatabase_obj = DataBaseHelper.getInstance().getDb();
listView1 = ( ListView ) findViewById(R.id.list);
cursor = sqlitedatabase_obj.rawQuery("SELECT _id, Key_ProductName , Key_SellingPrice FROM APPARELS_SUBCAT_BRAND WHERE Key_ProductName LIKE ? AND Key_SellingPrice LIKE ? ",new String[]{"%","%"});
final SimpleCursorAdapter simple=new SimpleCursorAdapter(this, R.layout.appareal_listview_text ,cursor, new String[]{"Key_ProductName","Key_SellingPrice"} , new int[] {R.id.title_info_txt_v,R.id.description_info_txt_v});
setListAdapter(simple);
}
@Override
public void onListItemClick(ListView parent, View view, int position,
long id) {
//position_list_v = position;
Intent intent = new Intent(ApparelsSubcatBrand.this,BuyNowOffline.class);
Cursor cursor = (Cursor)adapter.getItem(position);
intent.putExtra("product_id", cursor.getInt(cursor.getColumnIndex("Key_Product_ID")));
startActivity(intent);
}
单击事件未生成。这是我此活动的总代码。我希望当我单击第一个项目时,它会从数据库中为该项目检索相应的 product_id