objImageButton.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View v) {
if(checkDiscrepancySubmitted(final_position))
{
// TODO Auto-generated method stub
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(FragmentActivity.this);
alertDialogBuilder
.setMessage("Do you wish to delete the logged defect ?")
.setCancelable(false)
.setPositiveButton("Yes",new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog,int id)
{
int idButton=objImageButton.getId();
EditText objNewEditText=(EditText) findViewById(idButton);
objNewEditText.setTextColor(R.color.blue);
removeDefect(final_position,idButton,objNewEditText);
Toast.makeText(FragmentActivity.this, "Unsaved defects deleted.", Toast.LENGTH_SHORT).show();
}
})
.setNegativeButton("No",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
dialog.cancel();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
return false;
}
return false;
}
});
따라서 볼 수 있듯이 onLongClick()
내부에는 조건이 있습니다. 이 조건이 참인 경우에만 onLongClick()이 작동해야합니다. 기본적으로 조건이 true 인 경우에만 Listener 함수가 호출되기를 원합니다. 어떻게해야합니까?onLongClick()은 조건이 true 인 경우에만 작동해야합니다.
이렇게하면 onLongClick()이 전혀 작동하지 않습니다. –