【发布时间】:2016-01-05 00:17:50
【问题描述】:
我有一个带按钮的布局。
onclick 显示一个 AlertDialog,带有 Ok 和 Cancel 选项。我希望如果单击“确定”,布局中的按钮就会消失。
到目前为止,这是我的代码:
总的来说,我有这个功能:
public void requestCheckButton(View view) {
RequestAccepted ra = new RequestAccepted(this);
}
RequestAccepted 函数:
public class RequestAccepted {
Context context;
public RequestAccepted(final Context context){
this.context = context;
final AlertDialog.Builder popDialog = new AlertDialog.Builder(context);
final SeekBar seek = new SeekBar(context);
seek.setMax(11); // Para tener incrementos de 5 min
seek.setProgress(1);
popDialog.setTitle("¿En cuánto tiempo puedes llegar?");
popDialog.setMessage("5 min");
popDialog.setView(seek);
popDialog.setPositiveButton("Mandar", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(context, "Presionaste Mandar", Toast.LENGTH_SHORT).show();
}
});
final AlertDialog dialog = popDialog.create();
seek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
int progress = 1;
public void onProgressChanged(SeekBar seekBar, int progressV, boolean fromUser) {
progress = progressV;
}
public void onStartTrackingTouch(SeekBar arg0) {
}
public void onStopTrackingTouch(SeekBar seekBar) {
//Por cada incremento se suman 5 min
dialog.setMessage((progress)*5 +" min");
}
});
dialog.show();
}
【问题讨论】:
标签: android visibility android-alertdialog android-button