Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!