gpt4 book ai didi

android - onLongClick() 只有在条件为真时才有效

转载 作者:行者123 更新时间:2023-11-29 18:04:15 26 4
gpt4 key购买 nike

 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() 才起作用。基本上我希望仅当条件为真时才调用 Listener 函数。我如何才能做到这一点?

最佳答案

可能会解决您的问题。您可以将返回类型更改为“true”。

关于android - onLongClick() 只有在条件为真时才有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14190214/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com