我使用以下代码:
public class Settings extends Activity implements OnClickListener {
private Activity activity;
private AlertDialog.Builder builder;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.settings);
Button bAdd = (Button) findViewById(R.id.bAdd);
bAdd.setOnClickListener(this);
activity = this;
builder = new AlertDialog.Builder(activity);
builder.setMessage("message")
.setTitle("title");
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.bAdd:
AlertDialog dialog = builder.create();
break;
}
}
}
但是由于某种原因,我的弹出窗口没有出现,也什么都不做。关于导致此故障的原因有什么想法吗?谢谢!