我有一个Button按钮,它可以在ListView中选中所有选中的CheckBox,并显示AlertDialog中所有选中的复选框。
我在for循环中迭代所有元素,我有一个positiveButton和一个negativeButton - 当我按下negativeButton时,我想取消所有对话框,然后返回到应用程序。
但相反,当我按下negativeButton时,它会逐个迭代。
btnDialog = (Button) findViewById(R.id.btnDialog);
btnDialog.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
StringBuffer responseText = new StringBuffer();
//responseText.append("הפריטים שנבחרו הם: \n");
Models models = new Models();
//List<Models> modelList = new ArrayList<>();
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
alertDialogBuilder.setTitle("Diet Product");
responseText.append("הפריטים שנבחרו הם: \n");
Log.d(responseText.toString(), msg);
for (int i = 0; i < (modelList.size()); i++) {
models = modelList.get(i);
if (models.isSelected()) {
alertDialogBuilder
.setMessage(responseText.append(models.getName() + " : " + models.getProtein() + "\n"))
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// if this button is clicked, close current activity
MainActivity.this.finish();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
}
}
});
答案 0 :(得分:1)
我相信我来解决这个问题
library(ggplot2)
ggplot(df, aes(x=Month, y=Quantity, colour=Year)) +
geom_point()