这是我正在使用的删除代码。我正试图对它进行一些验证,可能会出现一个警告对话框并要求确认?
String vowels = "aeiou";
String inputString = bf.readLine().toLowerCase();
for (int i = 0; i < inputString.length(); i++) {
char c = inputString.charAt(i);
boolean isVowel = false;
for (int j = 0; j < vowels.length(); j++) {
if (vowels.charAt(j) == c) {
isVowel = true;
break;
}
}
System.out.print(isVowel ? c : (char)(c + 1));
}
答案 0 :(得分:1)
试试这个!!!
private void setupListener() {
listEntries.setOnItemLongClickListener(
new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapter,
View item, int pos, long id) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
context);
// set title
alertDialogBuilder.setTitle("Your Title");
// set dialog message
alertDialogBuilder
.setMessage("Click yes to exit!")
.setCancelable(false)
.setPositiveButton("Yes",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
items.remove(pos);
entryAdapter.notifyDataSetChanged();
writeStrings();
}
})
.setNegativeButton("No",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
dialog.cancel();
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
}
});
return true;
}
});
}
答案 1 :(得分:0)
您可以使用AlertDialog.Builder
,有关详细信息,请参阅此处的教程http://www.mkyong.com/android/android-alert-dialog-example/