Ice*_*ind 2 android android-alertdialog
我似乎遇到了创建AlertDialog的问题.我想要做的是创建一个自定义AlertDialog,当单击一个特定的RadioButton时弹出.这是我的相关代码:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
m_Minutes = -1;
m_this=this;
String prefName = getString(R.string.prefsfile);
SharedPreferences settings = getSharedPreferences(prefName, 0);
String defaultTextBackMessage = settings.getString("textBackMessage", getString(R.string.defaultTextBackMessage));
EditText txtMessage = (EditText)findViewById(R.id.editText1);
txtMessage.setText(defaultTextBackMessage);
final Button button = (Button)findViewById(R.id.button1);
final RadioButton manualButton = (RadioButton)findViewById(R.id.radio0);
final RadioButton button15 = (RadioButton)findViewById(R.id.radio1);
final RadioButton button30 = (RadioButton)findViewById(R.id.radio2);
final RadioButton customButton = (RadioButton)findViewById(R.id.radio3);
manualButton.setChecked(true);
customButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Context c = v.getContext();
LayoutInflater factory = LayoutInflater.from(v.getContext());
final View minuteEntryView = factory.inflate(R.layout.customtime, null);
AlertDialog ad = AlertDialog.Builder(c).create(); // this is the trouble line
}
});
Run Code Online (Sandbox Code Playgroud)
我在线上收到错误AlertDialog ad = AlertDialog.Builder(c).create();.我得到的错误是The Method Builder(Context) is undefined for the type AlertDialog.但是,很明显,Google API Docs确实有一个Builder构造函数.我究竟做错了什么?
你不应该这样说......
AlertDialog ad = new AlertDialog.Builder(c).create();
Run Code Online (Sandbox Code Playgroud)
你忘记了newkeyWord ..正如你可以清楚地看到的那样,它没有发现Method,这意味着你以通常的方式调用它的构造函数,但是你调用方法的方式.
| 归档时间: |
|
| 查看次数: |
1251 次 |
| 最近记录: |