PDA

View Full Version : مشکل با ساخت لیست علاقه مندی ها مشکل سورس من کجاست؟



android69
یک شنبه 22 تیر 1393, 21:19 عصر
این سورس منه نمیدونم چرا عمل نمیکنه!!!!:گریه:



favorit.setOnClickListener(new OnClickListener() {


@Override
public void onClick(View arg0) {


Cursor cursor = G.database.rawQuery("SELECT * FROM data ", null);
while (cursor.moveToNext()) {
int id = cursor.getInt(cursor.getColumnIndex("id"));
String title = cursor.getString(cursor.getColumnIndex("title"));
String desc = cursor.getString(cursor.getColumnIndex("desc"));
}
cursor.close();


G.database.execSQL("UPDATE data SET flag='yes' WHERE like='no'");
}
});







private ListView listfavorit;
public AdapterData adapterfavorit;
StructData favorit = new StructData();
public static ArrayList<StructData> favorits = new ArrayList<StructData>();




@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_fav);
listfavorit = (ListView) findViewById(R.id.lst);
adapterfavorit = new AdapterData(favorits);


favorits.clear();
Cursor cursor = G.database.rawQuery("SELECT * FROM data where flag='yes'", null);
while (cursor.moveToNext()) {
StructData sdata = new StructData();
favorit.Get_id = cursor.getInt(cursor.getColumnIndex("id"));
favorit.Get_title = cursor.getString(cursor.getColumnIndex("title"));
favorit.Get_desc = cursor.getString(cursor.getColumnIndex("desc"));


favorits.add(favorit);
}
cursor.close();


adapterfavorit.notifyDataSetChanged();
listfavorit.setAdapter(adapterfavorit);
}
}

چرا با کلیک روی دکمه ایتم به لیست اضافه نمیشه؟چطوری ایتم رو حذف و اضافه کنم؟ممنون میشم کمک کنید.