AlertDialogを作成する際に問題が発生しているようです。私がしようとしているのは、特定のRadioButtonがクリックされたときにポップアップするカスタムAlertDialogを作成することです。ここに私の関連するコードは次のとおりです。AlertDialogの作成に関する問題
@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
}
});
私はAlertDialog ad = AlertDialog.Builder(c).create();
行でエラーを取得しています。私が得ているエラーはThe Method Builder(Context) is undefined for the type AlertDialog
です。しかし、明らかに、Google API DocsにはBuilderコンストラクタがあります。私は間違って何をしていますか?
エラーログを表示できますか? –
@Suri - ランタイムエラーではなく、コンパイルエラーが発生しています – Icemanind
私は同じ問題に直面しました。私は "新しい"を忘れてしまったとは思いません。私は休憩の男が必要です! – Ishaan