Reputation: 33
I have a AlertDialog.Builder in my Fragment Page and it shows three EditText (in a xml file). Now I'd like to add a button at the top of the AlertDialog and on its click change the text of two of them.
It is like:
Button : Get coordinates
1st EdiText : latitude
2st EdiText : longitude
Upvotes: 0
Views: 665
Reputation: 1828
If you want a button added in xml file to be displayed in AlertDialog, just inflate the layout
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setCancelable(false);
builder.setView(layout);
where "layout" is inflated view
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.activity_filename,null); // specify your xml layout here
then use "layout" to get id of the button
Button btn=(Button)layout.findViewById(R.id.getCoordBtn);
add click listener to it and perform whatever you want
Upvotes: 2