Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Android Programming: Android Studio: Google Maps API I have this part of code in my MapsActivity.java that keeps crashing when I click on the polygon,
Android Programming: Android Studio: Google Maps API
I have this part of code in my MapsActivity.java that keeps crashing when I click on the polygon, how do i fix it?
==================================================================================================== mMap.setOnPolygonClickListener(new GoogleMap.OnPolygonClickListener() { @Override public void onPolygonClick(Polygon polygon) { AlertDialog.Builder mBuilder = new AlertDialog.Builder(MapsActivity.this); @SuppressLint("InflateParams") View mView = getLayoutInflater().inflate(R.layout.dialog_info, null); final NumberPicker numberPicker = (NumberPicker) mView.findViewById(R.id.hours); numberPicker.setMinValue(0); numberPicker.setMaxValue(24); Button mPay = (Button) mView.findViewById(R.id.btnPay); mPay.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(numberPicker.getValue() > 0){ Toast.makeText(MapsActivity.this,"Thank You", Toast.LENGTH_SHORT).show(); }else{ Toast.makeText(MapsActivity.this, "Please pick your Hours", Toast.LENGTH_LONG).show(); } } }); mBuilder.setView(mView); AlertDialog dialog = mBuilder.create(); dialog.show(); } });
===============================================================================================
dialog_info.xml
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started