點擊按鈕 讓listview 所有edittext 顯示可編輯,並顯示刪除按鈕
if(null!=dataList && 0<dataList.size()){for(int i=0;i<dataList.size();i++){view=listView.getChildAt(i);EditText edittxt=(EditText)view.findViewById(R.id.txt_number);Button btnprice=(Button)view.findViewById(R.id.btn_price);if(null!=edittxt){edittxt.setEnabled(true);}if(null!=btnprice){btnprice.setVisibility(View.VISIBLE);}}}
第二步重寫adapter 在getView設定button事件
holder.btdel.setTag(position);holder.btdel.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {views=v;// TODO Auto-generated method stubnew AlertDialog.Builder(context).setTitle("提示").setMessage("確認要刪除嗎?").setPositiveButton("確定",new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {// TODO Auto-generated method stublistdata.remove(listdata.get(Integer.valueOf(views.getTag().toString()))); notifyDataSetChanged();}}).setNegativeButton("取消", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {// TODO Auto-generated method stubdialog.dismiss();}}).show();}});