我只希望在满足某些条件时(当给出姓名和姓氏有效时)解除我的 <div id="Options">
<?php
if (!empty($financialYear->budget_items)) {
foreach ($financialYear->budget_items as $i => $item) {
?>
<div class="item-div">
<?php echo $this->Form->input('budget_items.' . $i . '.id'); ?>
<div class="col-sm-12">
<?php
echo $this->Form->input('budget_items.' . $i . '.item_number', ['placeholder' => __('Item Number'), 'class' => 'form-control', 'type' => 'text']);
?>
</div>
<div class="col-sm-6">
<?php
echo $this->Form->input('budget_items.' . $i . '.item_title', ['placeholder' => __('Item Title'), 'class' => 'form-control', 'type' => 'text']);
?>
</div>
<div class="col-sm-6">
<?php
echo $this->Form->input('budget_items.' . $i . '.amount', ['placeholder' => __('Amount'), 'class' => 'form-control']);
?>
</div>
<div class="col-sm-6">
<?php
echo $this->Form->input('budget_items.' . $i . '.active', ['placeholder' => __('Active'), 'class' => 'form-control']);
?>
</div>
<div class="col-sm-6">
<a href="#" class="btn btn-danger btn-sm remove-item" ><i class="fa fa-close"></i></a>
</div>
<div class="clearfix"></div>
</div>
<?php }
?>
<div class="col-lg-12">
<a href="#" class="btn btn-primary add-item"><i class="fa fa-plus"></i> <?php echo __('Add Items') ?></a>
</div>
<?php
} else {
?>
<div class="col-sm-12">
<?php
echo $this->Form->input('budget_items.0.item_number', ['placeholder' => __('Item Number'), 'class' => 'form-control']);
?>
</div>
<div class="col-sm-6">
<?php
echo $this->Form->input('budget_items.0.item_title', ['placeholder' => __('Item Title'), 'class' => 'form-control', 'class' => 'form-control', 'type' => 'text']);
?>
</div>
<div class="col-sm-6">
<?php
echo $this->Form->input('budget_items.0.amount', ['placeholder' => __('Amount'), 'class' => 'form-control']);
?>
</div>
<div class="col-sm-12">
<?php
echo $this->Form->input('budget_items.0.active', ['placeholder' => __('Active'), 'class' => 'form-control']);
?>
</div>
<?php } ?>
</div>
- 否则它应始终位于父视图的顶部。我的代码是这样的:
AlertDialog
使用此代码,无论输入文本如何,按下按钮时 final AlertDialog.Builder alert = new AlertDialog.Builder(this);
final TextView instructions = new TextView(this);
instructions.setText(R.string.alert_enter_data);
final EditText name = new EditText(this);
name.setHint(R.string.name);
final EditText surname = new EditText(this);
surname.setHint(R.string.surname);
LinearLayout ll=new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
ll.addView(instructions);
ll.addView(name);
ll.addView(surname);
alert.setView(ll);
alert.setNeutralButton(R.string.enter, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String name_txt = name.getText().toString();
String surname_txt = surname.getText().toString();
if ((name_txt.length() > 1) && (surname_txt.length() > 1)) {
dialog.dismiss();
}
}
});
final AlertDialog alert_dialog = alert.create();
alert_dialog.setCanceledOnTouchOutside(false);
alert_dialog.show();
都会消失。然后我尝试了这个:
AlertDialog
但是这样我根本就得不到巴顿。警报对话框仅包含EditText字段。
答案 0 :(得分:1)
alert.setNeutralButton(R.string.enter, new DialogInterface.OnClickListener() {
和
Button b = alert.getButton(AlertDialog.BUTTON_POSITIVE);
都是不同的按钮。
尝试
按钮b = alert.getButton(AlertDialog.BUTTON_NEUTRAL);