I seem to be having an issue creating an AlertDialog. What I am trying to do is create a custom AlertDialog that pops up when a specific RadioButton is clicked. Here is my relevant code:
@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
}
});
I am getting an error at the AlertDialog ad = AlertDialog.Builder(c).create(); line. The error I am getting is The Method Builder(Context) is undefined for the type AlertDialog. Clearly, however, the Google API Docs does have a Builder constructor. What am I doing wrong?
should’t you say this…
you forgot
newkeyWord..As you can clearly see, its saying no Method found, which means you are calling its constructor in usual way but in the way you call a method.