0
sqlite 데이터를 사용하여 사용자 지정 listview가 있습니다. Listview에는 3 개의 텍스트 뷰와 1 개의 체크 박스가 있습니다. 목록 뷰에서 체크 된 항목의 값으로 sqlite 데이터베이스를 업데이트하려고합니다. 거의 모든 단계를 수행했지만 항목을 2 개 선택하여 업데이트하려고 시도하면 sqlite 데이터베이스에서 하나의 레코드 만 업데이트됩니다. 선택한 레코드를 업데이트하고 싶습니다. 내 코드는 Screen입니다. 저장 버튼 클릭시이 작업을 수행하고 싶습니다. sqlite의 선택된 listitems id가 str1 변수에 저장 중입니다.안드로이드 sqlite 데이터베이스에서 확인 된 사용자 정의 listview 레코드를 업데이 트하는 방법?
btnSaveCancellation.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
long itemCount = listVCancelCollection.getCount();
for(i=0;i<=itemCount-1;i++)
{
if(chkConfirm.isChecked())
{
final long str1 = list_collection.get(i).getId();
AlertDialog.Builder alertDialogBuild=new AlertDialog.Builder(CancelCollection.this, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
alertDialogBuild.setTitle("Cancel Collection?");
alertDialogBuild.setCancelable(false).setPositiveButton
("Yes", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
dialog.cancel();
displayReasonPopup();
}
private void displayReasonPopup()
{
Button btnAlert;
LayoutInflater layoutInflater = LayoutInflater.from(CancelCollection.this);
View promptView = layoutInflater.inflate(R.layout.input_dialog_reason, null);
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(CancelCollection.this);
alertDialogBuilder.setView(promptView);
alertDialogBuilder.setTitle("Reason");
final EditText editReason = (EditText) promptView.findViewById(R.id.edittext_reason);
editReason.setTypeface(ttf);
alertDialogBuilder.setCancelable(false)
.setPositiveButton("Save", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id)
{
String edtString=editReason.getText().toString().trim();
String strUpdate="UPDATE Customer_Collection SET Collection_Status = '0' , "
+ "Cancel_Notes = '"+edtString+"'"
+ "WHERE Customer_ID = '"+strCustomerID+"'"
+ " AND Customer_Collection_ID = '"+str1+"'";
SQLiteStatement statement = db.compileStatement(strUpdate);
db.beginTransaction();
statement.execute();
db.setTransactionSuccessful();
db.endTransaction();
}
})
.setNegativeButton("Cancel",
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id)
{
dialog.cancel();
}
});
// create an alert dialog
final AlertDialog alertDD = alertDialogBuilder.create();
alertDD.show();
}
}).setNegativeButton("No", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
dialog.cancel();
}
});
AlertDialog alertDialog = alertDialogBuild.create();
alertDialog = alertDialogBuild.setMessage("Do you want to cancel the selected collections?").show();
}
}
}
});
내가 많이 시도했지만 할 수없는이 내 목록보기 항목에 속하는에 속하는 확인해야합니다. 내 코드에서 변경해야 할 사항을 알려주십시오. –