1
當我插入數據,然後該數據顯示在custome列表視圖,也把按鈕列表視圖所以,現在當點擊按鈕在那時執行一些操作,那麼我需要創建onClickListener的按鈕,所以當延伸ListActivity再沒有在我器件的應用在Android中運行onClickListener .... 我也送代碼這個....當擴展ListActivity然後不工作onClickListener
public class MydatabaseforlistActivity extends ListActivity {
DbHelper dbhelper;
SQLiteDatabase db;
Button btnEdit,btnDel;
String[] id;
String[] title;
int size;
SimpleCursorAdapter adapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*{
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);*/
//setContentView(R.layout.listcarda);
dbhelper = new DbHelper(this);
dbhelper.oninsert("HELLO");
dbhelper.oninsert("hjkhkjhl");
dbhelper.oninsert("happy mother");
dbhelper.oninsert("happy sorry");
db=dbhelper.getReadableDatabase();
Cursor c = db.query(DbHelper.TABLE_NAME, new String[] { DbHelper.U_ID,
DbHelper.TITLE }, null, null, null, null, null);
int i = 0;
c.moveToFirst();
size = c.getCount();
id = new String[size];
title = new String[size];
while (c.moveToNext()) {
id[i] = c.getString(1);
// title[i] = c.getString(2);
i++;
c.moveToNext();
}
c.close();
db.close();
//lv = getListView();
setListAdapter(new Notes(this));
ü沒有寫代碼onclicklistener! ! – Farhan 2012-03-16 05:43:20