当前位置:优学网  >  在线题库

从“多个”对话框中获取数据,并将其放入窗口标记中

发表时间:2022-07-24 00:22:26 阅读:110

我应该把所有放在对话框中的信息放在谷歌地图的窗口标记中,作为对像迷你配置文件一样放置标记的人的描述,必须来自将信息放在对话框中的同一个人.下面我放对话框代码和窗口标记代码.谢谢

对话

 add_address.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            View viewcustom = getLayoutInflater().inflate(R.layout.customdialog, null);
                        EditText edt1 = viewcustom.findViewById(R.id.description);
                        EditText edt2 = viewcustom.findViewById(R.id.age);
                        EditText edt3 = viewcustom.findViewById(R.id.hobby);
                        EditText edt4 = viewcustom.findViewById(R.id.city);
                        EditText edt5 = viewcustom.findViewById(R.id.address);

            final Alert对话.Builder alert对话 = new Alert对话.Builder(requireActivity())
                    .setView(viewcustom)
                    .setPositiveButton("Ok", (dialogInterface, i) -> {
                        String description = edt1.getText().toString();
                        String age = edt2.getText().toString();
                        String Hobby = edt3.getText().toString();
                        String City = edt4.getText().toString();
                        String address = edt5.getText().toString();

                        Toast.makeText(requireContext(), description, Toast.LENGTH_SHORT).show();

                firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
                reference = FirebaseDatabase.getInstance().getReference("Users").child(firebaseUser.getUid()).child("address");
                reference.setValue(address);
            });
            alert对话.setNegativeButton("Cancel", null);
            alert对话.create().show();
            //startAutoCompleteIntent();
        }
    });

窗口标记

googleMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
            @Nullable
            @Override
            public View getInfoContents(@NonNull Marker marker) {

                View windowView = View.inflate(getApplicationContext(), R.layout.window_information_map, null);

                TextView Description = (TextView)findViewById(R.id.Description);
                TextView age = (TextView)findViewById(R.id.Age);
                TextView city = (TextView)findViewById(R.id.City);
                TextView work = (TextView)findViewById(R.id.Work);
                TextView hobby = (TextView)findViewById(R.id.Hobby);

                return windowView;
            }

            @Nullable
            @Override
            public View getInfoWindow(@NonNull Marker marker) {
                return null;
            }
        });
    }
🎖️ 优质答案
相关问题