0

Hello everyone i have a problem with my application onMarkerClick it works well till i click the marker second time the application crashes here is the code:

mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
                    @Override
                    public boolean onMarkerClick(Marker marker) {


                        builder.setTitle("Set radius in meters:");
                        builder.setMessage("Info: The radius is set by default on 500 meters");

                        // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
                        input.setInputType(InputType.TYPE_CLASS_NUMBER);
                        builder.setView(input);

                        // Set up the buttons
                        builder.setPositiveButton("Set", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                m_Text = Integer.parseInt(input.getText().toString());
                                Toast.makeText(getBaseContext(), "Radius set to: " + m_Text + " meters;", Toast.LENGTH_LONG).show();
                                circle.setRadius(m_Text);
                            }
                        });
                        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.cancel();
                            }
                        });

                        builder.show();
                        return false;
                    }
                });

The error is The specified child already has a parent. You must call removeView() on the child's parent first.
and the line is where return false is.

Edited by Stefan_1: Title change

2
Contributors
3
Replies
20
Views
2 Years
Discussion Span
Last Post by Stefan_1
0

Hard to say without seeing more of the code. Often the problem is how you inflate components or how you are discharging views once not need it. I would have to see more of the code, sorry

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.