Ejemplo n.º 1
0
 /*----------Method to create an AlertBox ------------- */
 protected void alertbox(String title, String mymessage) {
   AlertDialog.Builder builder = new AlertDialog.Builder(this);
   builder
       .setMessage("Your Device's GPS is Disable")
       .setCancelable(false)
       .setTitle("** Gps Status **")
       .setPositiveButton(
           "Gps On",
           new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int id) {
               // finish the current activity
               finish();
               Intent myIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
               startActivity(myIntent);
               dialog.cancel();
             }
           })
       .setNegativeButton(
           "Cancel",
           new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int id) {
               // cancel the dialog box
               dialog.cancel();
             }
           });
   AlertDialog alert = builder.create();
   alert.show();
 }
 @Override
 protected void onPause() {
   super.onPause();
   if (mAlertDialog != null && mAlertDialog.isShowing()) {
     mAlertDialog.dismiss();
   }
 }
Ejemplo n.º 3
0
 @SuppressLint("NewApi")
 public void closeDialog() {
   if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD_MR1) return;
   if (null != dialog && dialog.isShowing()) {
     dialog.cancel();
   }
 }
Ejemplo n.º 4
0
  /** Asks user to enable GPS */
  private void showGPSDisabledAlertToUser() {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder
        .setMessage(getStringResource(R.string.enable_gps))
        .setCancelable(false)
        .setPositiveButton(
            getStringResource(R.string.yes),
            new DialogInterface.OnClickListener() {

              @Override
              public void onClick(DialogInterface dialog, int id) {
                Intent callGPSSettingIntent =
                    new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                startActivity(callGPSSettingIntent);
              }
            });
    alertDialogBuilder.setNegativeButton(
        getStringResource(R.string.cancel),
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
          }
        });
    AlertDialog alert = alertDialogBuilder.create();
    alert.show();
  }
  private void showPopUpCashless() {
    final CharSequence[] items = {"Only Cashless", "All garages"};
    AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this);
    helpBuilder.setTitle("Make Selection");

    helpBuilder.setSingleChoiceItems(
        items,
        0,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int item) {
            Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
            radioTimeSelected = item;
            ShowMapActivity.cashSelected = item;
          }
        });

    helpBuilder.setPositiveButton(
        "Confirm",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
            Toast.makeText(SearchSettingsActivity.this, "Success", Toast.LENGTH_SHORT).show();
          }
        });

    // Remember, create doesn't show the dialog
    AlertDialog helpDialog = helpBuilder.create();
    helpDialog.show();
  }
  // Lifecycle method to handle menu option actions
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    // Allows the user to choose whether to take a new photo, or choose a photo from the Gallery
    if (id == R.id.action_camera) {
      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      builder.setItems(
          R.array.camera_choices,
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int position) {
              if (position == REQUEST_IMAGE_CAPTURE) {
                takePicture();
              } else if (position == REQUEST_IMAGE_CHOOSE) {
                Intent choosePhotoIntent = new Intent(Intent.ACTION_GET_CONTENT);
                choosePhotoIntent.addCategory(Intent.CATEGORY_OPENABLE);
                choosePhotoIntent.setType("image/*");
                startActivityForResult(choosePhotoIntent, REQUEST_IMAGE_CHOOSE);
              }
            }
          });

      AlertDialog dialog = builder.create();
      dialog.show();
    }
    // Refreshes the feed by re-loading the freed fragment (which in turn calls the API for new
    // data)
    if (id == R.id.action_refresh) {
      FragmentTransaction transaction = getFragmentManager().beginTransaction();
      transaction.replace(R.id.content_frame, new FeedFragment()).commit();
    }

    return super.onOptionsItemSelected(item);
  }
Ejemplo n.º 7
0
 private void buildAlertMessageNoGps() {
   final AlertDialog.Builder builder = new AlertDialog.Builder(this);
   builder
       .setMessage(" GPS & LOCATIONSERVICE is Required, do you want to enable it?")
       .setCancelable(false)
       .setPositiveButton(
           "Yes",
           new DialogInterface.OnClickListener() {
             public void onClick(
                 @SuppressWarnings("unused") final DialogInterface dialog,
                 @SuppressWarnings("unused") final int id) {
               startActivity(
                   new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
             }
           })
       .setNegativeButton(
           "No",
           new DialogInterface.OnClickListener() {
             public void onClick(
                 final DialogInterface dialog, @SuppressWarnings("unused") final int id) {
               dialog.cancel();
             }
           });
   final AlertDialog alert = builder.create();
   alert.show();
 }
  private void promptUserForGPS() {
    /*
     * create dialogue for user to turn on GPS or skip to userform
     */

    AlertDialog.Builder builder = new AlertDialog.Builder(MY_CONTEXT);
    builder
        .setMessage("GPS is disabled. Enable GPS?")
        .setCancelable(false)
        .setPositiveButton(
            "Change GPS Settings",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                /*
                 * User is directed to phone settings to turn on GPS
                 * the answer is caught in onActivityResult with SETTINGS_ACTIVITY_KEY
                 */
                Intent myIntent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
                startActivityForResult(myIntent, SETTINGS_ACTIVITY_KEY);
              }
            })
        .setNegativeButton(
            "Ignore",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                // just dismiss dialog
              }
            });

    AlertDialog dialog = builder.create();
    dialog.show();
  }
Ejemplo n.º 9
0
  public void showGagne(View view) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    end = System.currentTimeMillis();
    elapsed = (end - start) / 1000;
    builder
        .setTitle(R.string.gagne)
        .setMessage("Vous avez gagné en " + elapsed + " secondes")
        .setPositiveButton(
            R.string.ok,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int id) {
                finish();
              }
            })
        .setNegativeButton(
            R.string.restart,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int id) {
                restart();
              }
            });

    AlertDialog dialog = builder.create();
    dialog.show();
  }
Ejemplo n.º 10
0
  /**
   * Confirms if the user wants to really delete the photo
   *
   * @param photoId
   * @param activity
   */
  public void confirmDelete(final int photoId, final DetailActivity activity) {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder
        .setMessage(getStringResource(R.string.confirm_delete))
        .setCancelable(false)
        .setPositiveButton(
            getStringResource(R.string.yes),
            new DialogInterface.OnClickListener() {

              @Override
              public void onClick(DialogInterface dialog, int id) {
                deletePhoto(photoId);
                if (activity != null) {
                  Intent resultIntent = new Intent();
                  resultIntent.putExtra("id", photoId);
                  resultIntent.putExtra("position", activity.position);
                  activity.setResult(RESULT_DELETE, resultIntent);
                  activity.finish();
                }
              }
            });
    alertDialogBuilder.setNegativeButton(
        getStringResource(R.string.cancel),
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
          }
        });
    AlertDialog alert = alertDialogBuilder.create();
    alert.show();
  }
Ejemplo n.º 11
0
 public static void installBusyBox(SherlockActivity context) {
   DialogHelper.context = context;
   AlertDialog.Builder builder = new AlertDialog.Builder(context);
   builder
       .setMessage(R.string.installbusybox)
       .setCancelable(false)
       .setPositiveButton(
           R.string.button_ok,
           new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int id) {
               Intent goToMarket = null;
               goToMarket =
                   new Intent(
                       Intent.ACTION_VIEW, Uri.parse("market://details?id=stericson.busybox"));
               DialogHelper.context.startActivity(goToMarket);
               dialog.cancel();
             }
           })
       .setNegativeButton(
           R.string.button_abprt,
           new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int id) {
               dialog.cancel();
             }
           });
   AlertDialog alert = builder.create();
   alert.show();
 }
Ejemplo n.º 12
0
 private AlertDialog cancleTrackDialog(final String id) {
   LayoutInflater factory = LayoutInflater.from(this);
   /*中奖查询的查看详情使用余额查询的布局*/
   View view = factory.inflate(R.layout.usercenter_balancequery, null);
   final AlertDialog dialog = new AlertDialog.Builder(this).create();
   TextView title = (TextView) view.findViewById(R.id.usercenter_balancequery_title);
   TextView remind = (TextView) view.findViewById(R.id.usercenter_remind_text);
   remind.setVisibility(TextView.GONE);
   title.setText(R.string.cancel_add_num);
   TextView detailTextView = (TextView) view.findViewById(R.id.balanceinfo);
   detailTextView.setTextSize(18);
   detailTextView.setText(R.string.usercenter_cancleTrackRemind);
   Button cancleLook = (Button) view.findViewById(R.id.usercenter_balancequery_back);
   cancleLook.setOnClickListener(
       new OnClickListener() {
         public void onClick(View v) {
           dialog.cancel();
         }
       });
   Button okBtn = (Button) view.findViewById(R.id.usercenter_balancequery_ok);
   okBtn.setVisibility(Button.VISIBLE);
   okBtn.setOnClickListener(
       new OnClickListener() {
         public void onClick(View v) {
           dialog.cancel();
           cancleTrackNet(id);
         }
       });
   dialog.show();
   dialog.getWindow().setContentView(view);
   return dialog;
 }
Ejemplo n.º 13
0
  @Override
  public void uploadFinished(
      int requestType,
      int userId,
      int objectId,
      Object data,
      int uploadId,
      boolean status,
      String stringId) {
    if (requestType == CommonLib.COUPON_UPDATE) {
      if (!destroyed && status) {
        final AlertDialog successDialog;
        successDialog =
            new AlertDialog.Builder(this)
                .setTitle("Success")
                .setMessage("The coupon will be emailed to you shortly")
                .setPositiveButton(
                    getResources().getString(android.R.string.ok),
                    new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                      }
                    })
                .create();
        successDialog.show();

        refreshView();
      }
    }
  }
Ejemplo n.º 14
0
 @OnClick(R.id.editGroupPhoto)
 public void editPhoto() {
   AlertDialog.Builder builder = new AlertDialog.Builder(this);
   builder.setItems(R.array.camera_choices, mDialogInterface);
   AlertDialog dialog = builder.create();
   dialog.show();
 }
Ejemplo n.º 15
0
 private void showLocationServiceDisabledAlertToUser() {
   AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
   alertDialogBuilder
       // GPS is disabled in your device. Would you like to enable it?
       .setMessage(R.string.location_services_on_device_deactivated)
       .setCancelable(false)
       // Goto Settings Page To Enable GPS
       .setPositiveButton(
           R.string.activate_location_services_on_device,
           new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int id) {
               Intent callGPSSettingIntent =
                   new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
               startActivity(callGPSSettingIntent);
             }
           });
   alertDialogBuilder.setNegativeButton(
       "Fortryd",
       new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int id) {
           dialog.cancel();
         }
       });
   AlertDialog alert = alertDialogBuilder.create();
   alert.show();
 }
  /*
   * Functions for taking a picture
   */
  private void changePictureDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(MY_CONTEXT);
    builder
        .setMessage("A picture was already taken! Do you want to replace it?")
        .setCancelable(false)
        .setPositiveButton(
            "Retake Picture",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                /*
                 * User is directed to comments section
                 */
                takePicture();
              }
            })
        .setNegativeButton(
            "Keep current picture",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                // do nothing, dismiss dialog
              }
            });

    AlertDialog dialog = builder.create();
    dialog.show();
  }
Ejemplo n.º 17
0
  @Override
  public boolean onItemLongClick(final AdapterView<?> adapterView, View view, final int i, long l) {
    if (i == 0) {
      return false;
    }

    final ContactsSource.LocalContact contact =
        (ContactsSource.LocalContact) adapterView.getItemAtPosition(i);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(contact.displayName);

    if (contact.user != null) {
      builder.setItems(
          new CharSequence[] {
            getStringSafe(R.string.st_contacts_action_view),
            getStringSafe(R.string.st_contacts_action_share),
            getStringSafe(R.string.st_contacts_action_delete),
            getStringSafe(R.string.st_contacts_action_block),
            getStringSafe(R.string.st_contacts_action_block_and_delete)
          },
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
              if (i == 0) {
                viewInBookContact(contact);
              } else if (i == 1) {
                shareContact(contact);
              } else if (i == 2) {
                deleteContact(contact);
              } else if (i == 3) {
                blockContact(contact);
              } else if (i == 4) {
                blockDeleteContact(contact);
              }
            }
          });
    } else {
      builder.setItems(
          new CharSequence[] {
            getStringSafe(R.string.st_contacts_action_view),
            getStringSafe(R.string.st_contacts_action_delete),
          },
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
              if (i == 0) {
                viewInBookContact(contact);
              } else if (i == 1) {
                deleteContact(contact);
              }
            }
          });
    }
    AlertDialog contextMenu = builder.create();
    contextMenu.setCanceledOnTouchOutside(true);
    contextMenu.show();

    return true;
  }
Ejemplo n.º 18
0
  // Check for network status
  public boolean isOnline() {
    ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo netInfo = cm.getActiveNetworkInfo();
    if (netInfo != null && netInfo.isConnectedOrConnecting()) {
      return true;
    }
    // Instantiate an AlertDialog.Builder with its constructor for the Add item button
    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    // 2. Chain together various setter methods to set the dialog characteristics
    builder
        .setMessage(R.string.no_net_info)
        .setTitle(R.string.no_net)
        .setNegativeButton(
            R.string.close_add,
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                // User cancelled the dialog
              }
            });
    // Create the AlertDialog
    AlertDialog dialog = builder.create();
    dialog.show();
    return false;
  }
Ejemplo n.º 19
0
  private void showMsgDialog(final TodoType type, final String idStr, final String msg) {
    dismissSendMsgDialog();
    mSendSmsDialog =
        new AlertDialog.Builder(getActivity())
            .setTitle(R.string.dialog_title_sms_templet)
            .setMessage(msg)
            .setPositiveButton(
                R.string.dialog_btn_send_sms,
                new DialogInterface.OnClickListener() {

                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    sendSms(type, idStr);
                  }
                })
            .create();
    mSendSmsDialog.setOnDismissListener(
        new DialogInterface.OnDismissListener() {

          @Override
          public void onDismiss(DialogInterface dialog) {
            releaseHandleBtnlock();
          }
        });
    if (getActivity() != null && !getActivity().isFinishing()) {
      mSendSmsDialog.show();
    }
  }
Ejemplo n.º 20
0
  public void doActionOnAlert(View view) {
    // Ouvre une fenêtre de dialogue pour choisir une action à effectué sur l'alerte
    Resources res = getResources();
    final CharSequence[] items = res.getStringArray(R.array.list_action_alert);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(getString(R.string.title_list_alert_action));
    builder.setItems(
        items,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int item) {
            switch (item) {
              case OMW:
                manager.updateAlertOMW(currentAlert.getId());
                break;
              case POLICE:
                call911();
                break;
              case SAMU:
                callSamu();
                break;
              case WRONG_ALERT:
                manager.updateAlertBullshit(currentAlert.getId());
                break;
            }
          }
        });
    AlertDialog alert = builder.create();
    alert.show();
  }
Ejemplo n.º 21
0
  public void showIssue(final String issue) {
    LayoutInflater inflate =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflate.inflate(R.layout.touzhu_succe, null);
    final AlertDialog dialog = new AlertDialog.Builder(context).create();
    TextView textContent = (TextView) view.findViewById(R.id.touzhu_succe_text);
    Button ok = (Button) view.findViewById(R.id.touzhu_succe_button_sure);
    Button cancel = (Button) view.findViewById(R.id.touzhu_succe_button_share);
    ok.setBackgroundResource(R.drawable.loginselecter);
    cancel.setBackgroundResource(R.drawable.loginselecter);
    ok.setText(context.getString(R.string.dialog_issue_text_ok));
    cancel.setText(context.getString(R.string.dialog_issue_text_cancel));
    textContent.setText(context.getString(R.string.dialog_issue_text_content) + issue + "期。");
    ok.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            dialog.cancel();
            touzhuIssue(issue);
          }
        });
    cancel.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            dialog.cancel();
            finish();
          }
        });

    dialog.show();
    dialog.getWindow().setContentView(view);
  }
Ejemplo n.º 22
0
  private void showProfileDialog() {
    AlertDialog.Builder alert = new AlertDialog.Builder(BaseActivity.this);
    alert.setItems(
        new String[] {
          getResources().getString(R.string.view_profile),
          getResources().getString(R.string.log_out)
        },
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int item) {
            switch (item) {
              case 0:
                showUserProfile();
                break;
              case 1:
                logOut();
                break;
            }
          }
        });

    alert.setNegativeButton(
        R.string.no,
        new DialogInterface.OnClickListener() {

          public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
          }
        });

    AlertDialog ad = alert.create();
    ad.show();
  }
Ejemplo n.º 23
0
  public void showEmptyDialog() {

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.info).setMessage(R.string.no_new_orders);
    AlertDialog alert = builder.create();
    alert.show();
  }
  private void createDialog(final NavBarButton button) {
    final DialogInterface.OnClickListener l =
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int item) {
            onDialogClick(button, item);
            dialog.dismiss();
          }
        };

    String action = mResources.getString(R.string.navbar_actiontitle_menu);
    action = String.format(action, button.getClickName());
    String longpress = mResources.getString(R.string.navbar_longpress_menu);
    longpress = String.format(longpress, button.getLongName());
    String[] items = {
      action,
      longpress,
      mResources.getString(R.string.navbar_icon_menu),
      mResources.getString(R.string.navbar_delete_menu)
    };
    final AlertDialog dialog =
        new AlertDialog.Builder(mContext)
            .setTitle(mResources.getString(R.string.navbar_title_menu))
            .setItems(items, l)
            .create();

    dialog.show();
  }
Ejemplo n.º 25
0
  public void showErrorDialog() {

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.error).setMessage(R.string.error_loading_orders);
    AlertDialog alert = builder.create();
    alert.show();
  }
Ejemplo n.º 26
0
  private void showConfirmDialog(final int monthType) {
    // TODO Auto-generated method stub
    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    int[] month = {1, 3, 6, 12};
    int[] money = {11000, 31000, 61000, 110000};

    builder.setMessage("开通" + month[monthType] + "个月会员,需花费" + money[monthType] + "金币");
    builder.setPositiveButton(
        "开通",
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
            buyVIP(monthType);
          }
        });
    builder.setNegativeButton(
        "取消",
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub

          }
        });
    AlertDialog confDialog = builder.create();
    confDialog.show();
  }
Ejemplo n.º 27
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main12);

    ConnectivityManager cManager =
        (ConnectivityManager) getSystemService(this.CONNECTIVITY_SERVICE);
    NetworkInfo ninfo = cManager.getActiveNetworkInfo();
    if (ninfo != null && ninfo.isConnected()) {

    } else {
      AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
      builder1.setMessage("Sorry There is no internet please check your connection!");
      builder1.setCancelable(true);
      builder1.setPositiveButton(
          "I Will!",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
              dialog.cancel();
            }
          });

      AlertDialog alert11 = builder1.create();
      alert11.show();
    }

    itemlist = new ArrayList<RSSItem>();

    new RetrieveRSSFeeds().execute();
  }
Ejemplo n.º 28
0
 private void blockContact(final ContactsSource.LocalContact contact) {
   AlertDialog alertDialog =
       new AlertDialog.Builder(getActivity())
           .setMessage(
               getStringSafe(R.string.st_contacts_block).replace("{0}", contact.displayName))
           .setPositiveButton(
               R.string.st_yes,
               new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialogInterface, int i) {
                   runUiTask(
                       new AsyncAction() {
                         @Override
                         public void execute() throws AsyncException {
                           rpc(
                               new TLRequestContactsBlock(
                                   new TLInputUserContact(contact.user.getUid())));
                         }
                       });
                 }
               })
           .setNegativeButton(R.string.st_no, null)
           .create();
   alertDialog.setCanceledOnTouchOutside(true);
   alertDialog.show();
 }
Ejemplo n.º 29
-1
  private void showPopUpManuf(CharSequence[] data) {
    // CharSequence[] items = {"All models","Audi","Ford","Hyundai","Mahindra &
    // Mahindra","Maruti","Tata"};
    final CharSequence[] items = data;

    AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this);
    helpBuilder.setTitle("Make Selection");

    helpBuilder.setSingleChoiceItems(
        items,
        0,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int item) {
            Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
            radioTimeSelected = item;

            String slc = (String) items[item];
            if (item == 0) ShowMapActivity.manufSelected = null;
            else ShowMapActivity.manufSelected = slc;
          }
        });

    helpBuilder.setPositiveButton(
        "Confirm",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
            Toast.makeText(SearchSettingsActivity.this, "Success", Toast.LENGTH_SHORT).show();
          }
        });

    // Remember, create doesn't show the dialog
    AlertDialog helpDialog = helpBuilder.create();
    helpDialog.show();
  }
Ejemplo n.º 30
-1
  private void showPopUpDistance() {
    final CharSequence[] items = {"5 km", "10 km", "25 km", "50 km", "No limit"};
    final int[] arrDist = {5, 10, 25, 50};
    AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this);
    helpBuilder.setTitle("Make Selection");

    helpBuilder.setSingleChoiceItems(
        items,
        0,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int item) {
            Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
            radioTimeSelected = item;
            if (item == 4) ShowMapActivity.distSelected = -1;
            else ShowMapActivity.distSelected = arrDist[item];
          }
        });

    helpBuilder.setPositiveButton(
        "Confirm",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
            Toast.makeText(SearchSettingsActivity.this, "Success", Toast.LENGTH_SHORT).show();
          }
        });

    // Remember, create doesn't show the dialog
    AlertDialog helpDialog = helpBuilder.create();
    helpDialog.show();
  }