I want an info popup window for a google maps marker. The marker is already clickable. But when i init the instance of the MarkerInfo with the AlertDialog, my objects (TextView, Button) are always null.. Do you have any solutions?
Screen of exception: https://i.ibb.co/zXqBFX4/Bildschirmfoto-2021-12-04-um-10-25-02.png
public class MarkerInfo {
private Activity activity;
private AlertDialog dialog;
private Button button;
private ChargingStation station;
/**
* Constructor of info window
* @param activity of MainActivity
* @param station as object
*/
public MarkerInfo(Activity activity, ChargingStation station) {
this.activity = activity;
this.station = station;
}
/**
* Start popping up the window
*/
public void startLoading() {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
LayoutInflater inflater = activity.getLayoutInflater();
View view = inflater.inflate(R.layout.download_info_window, null);
builder.setView(view);
builder.setCancelable(false);
dialog = builder.create();
TextView op = view.findViewById(R.id.operator_no);
TextView street = view.findViewById(R.id.street_no);
TextView postal_code = view.findViewById(R.id.postal_code_no);
TextView area = view.findViewById(R.id.area_no);
op.setText(station.getOperator());
street.setText(station.getStreet());
postal_code.setText(station.getPostal_code());
area.setText(station.getArea());
button = view.findViewById(R.id.closeBtn);
button.setOnClickListener(view1 -> dialog.dismiss());
dialog.show();
}
[1]: https://i.ibb.co/zXqBFX4/Bildschirmfoto-2021-12-04-um-10-25-02.png