List of usage examples for android.widget Spinner setAdapter
@Override public void setAdapter(SpinnerAdapter adapter)
From source file:com.taokeba.fragment.RegistMoreFragment.java
private void spinnerSetAdapter(String[] data, Spinner spinner) { ArrayAdapter<String> aa = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line, data); //?spinner?UI spinner.setAdapter(aa); }
From source file:com.example.weiranfang.healthmonitoranalysis2014.HeatMapActivity.java
@Override protected void startDemo() { getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(40, -95), 2.8f)); // Set up the spinner/dropdown list Spinner spinner = (Spinner) findViewById(R.id.spinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.heatmaps_datasets_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new SpinnerActivity()); try {/* w w w . ja va 2s .c o m*/ JSONArray jsonArray = new GenerateJSONArrayTask().execute(new JSONSender()).get(); mLists.put(getString(R.string.tweet_heat_map), new DataSet(readItems(jsonArray), getString(R.string.police_stations_url))); mLists.put(getString(R.string.medicare), new DataSet(readItems(R.raw.medicare), getString(R.string.medicare_url))); } catch (JSONException e) { Toast.makeText(this, "Problem reading list of markers.", Toast.LENGTH_LONG).show(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } // Make the handler deal with the map // Input: list of WeightedLatLngs, minimum and maximum zoom levels to calculate custom // intensity from, and the map to draw the heatmap on // radius, gradient and opacity not specified, so default are used }
From source file:eu.power_switch.gui.dialog.DeveloperOptionsDialog.java
@NonNull @Override// w w w .jav a 2 s. c o m public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = getActivity().getLayoutInflater(); rootView = inflater.inflate(R.layout.dialog_developer_options, null); geofenceApiHandler = new GeofenceApiHandler(getActivity()); CheckBox checkBox_playStoreMode = (CheckBox) rootView.findViewById(R.id.checkBox_playStoreMode); checkBox_playStoreMode.setChecked(DeveloperPreferencesHandler.getPlayStoreMode()); checkBox_playStoreMode.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { DeveloperPreferencesHandler.setPlayStoreMode(isChecked); } }); Button resetShowcasesButton = (Button) rootView.findViewById(R.id.button_resetShowcases); resetShowcasesButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MaterialShowcaseView.resetAll(getContext()); } }); Button removeAllGeofences = (Button) rootView.findViewById(R.id.button_removeAllGeofences); removeAllGeofences.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { geofenceApiHandler.removeAllGeofences(); } }); Button forceUnknownExceptionDialog = (Button) rootView .findViewById(R.id.button_forceUnknownExceptionDialog); forceUnknownExceptionDialog.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { StatusMessageHandler.showErrorDialog(getContext(), new Exception("Unknown error during runtime!")); } }); Button forceUnhandledException = (Button) rootView.findViewById(R.id.button_forceUnhandledException); forceUnhandledException.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { throw new RuntimeException("Unhandled Exception"); } }); final Spinner spinnerLanguage = (Spinner) rootView.findViewById(R.id.spinner_language); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getContext(), R.array.locales, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerLanguage.setAdapter(adapter); spinnerLanguage.setSelection(getIndex(spinnerLanguage, DeveloperPreferencesHandler.getLocale().toString())); spinnerLanguage.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String localeString = spinnerLanguage.getItemAtPosition(position).toString(); DeveloperPreferencesHandler.setLocale(new Locale(localeString)); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); CheckBox checkBoxForceLanguage = (CheckBox) rootView.findViewById(R.id.checkBox_forceLanguage); checkBoxForceLanguage.setChecked(DeveloperPreferencesHandler.getForceLanguage()); checkBoxForceLanguage.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { DeveloperPreferencesHandler.setForceLanguage(isChecked); } }); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(rootView); builder.setTitle("Developer Options"); builder.setNeutralButton(android.R.string.ok, null); Dialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(false); // prevent close dialog on touch outside window dialog.show(); return dialog; }
From source file:com.microsoft.live.sample.ExplorerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.explorer);//from www. ja v a 2s . com LiveSdkSampleApplication app = (LiveSdkSampleApplication) getApplication(); mConnectClient = app.getConnectClient(); mOperationListener = new OperationListener(); mResponseBodyText = (EditText) findViewById(R.id.responseBodyText); mPathText = (EditText) findViewById(R.id.pathText); mRequestBodyText = (EditText) findViewById(R.id.requestBodyText); mRequestBodyTextView = (TextView) findViewById(R.id.requestBodyTextView); final Spinner httpMethodSpinner = (Spinner) findViewById(R.id.httpMethodSpinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, HTTP_METHODS); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); httpMethodSpinner.setAdapter(adapter); httpMethodSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case GET: case DELETE: hideRequestBody(); break; case POST: case PUT: showRequestBody(); break; default: { makeToast("Unknown HTTP method selected: " + httpMethodSpinner.getSelectedItem().toString()); break; } } } @Override public void onNothingSelected(AdapterView<?> parent) { // Do nothing. } }); findViewById(R.id.submitButton).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String path = mPathText.getText().toString(); String bodyString = mRequestBodyText.getText().toString(); if (TextUtils.isEmpty(path)) { makeToast("Path must not be empty."); return; } int selectedPosition = httpMethodSpinner.getSelectedItemPosition(); boolean httpMethodRequiresBody = selectedPosition == POST || selectedPosition == PUT; if (httpMethodRequiresBody && TextUtils.isEmpty(bodyString)) { makeToast("Request body must not be empty."); return; } mProgressDialog = showProgressDialog("Loading. Please wait..."); switch (selectedPosition) { case GET: { mConnectClient.getAsync(path, mOperationListener); break; } case DELETE: { mConnectClient.deleteAsync(path, mOperationListener); break; } case POST: { mConnectClient.postAsync(path, bodyString, mOperationListener); break; } case PUT: { mConnectClient.putAsync(path, bodyString, mOperationListener); break; } default: { makeToast("Unknown HTTP method selected: " + httpMethodSpinner.getSelectedItem().toString()); break; } } } }); }
From source file:de.domjos.schooltools.activities.LearningCardOverviewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.learning_card_overview_activity); this.initControls(); this.cmdLearningCardQueryStart.setOnClickListener(new View.OnClickListener() { @Override/*from ww w .ja v a2s. c o m*/ public void onClick(View v) { final LearningCardQueryTraining learningCardQueryTraining = new LearningCardQueryTraining(); if (cmdLearningCardQueryStart.getText().equals(getString(R.string.learningCard_query))) { final Dialog dialog = new Dialog(LearningCardOverviewActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.learning_card_dialog); dialog.setCancelable(true); final Spinner spLearningCardQuery = dialog.findViewById(R.id.spLearningCardQueries); final ArrayAdapter<LearningCardQuery> learningCardQueries = new ArrayAdapter<>( getApplicationContext(), android.R.layout.simple_spinner_item, MainActivity.globals.getSqLite().getLearningCardQueries("")); spLearningCardQuery.setAdapter(learningCardQueries); learningCardQueries.notifyDataSetChanged(); final Button btnStartSop = dialog.findViewById(R.id.cmdStart); btnStartSop.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { learningCardQueryTraining.setLearningCardQuery( learningCardQueries.getItem(spLearningCardQuery.getSelectedItemPosition())); learningCardQueryTraining.setID(MainActivity.globals.getSqLite() .insertOrUpdateLearningCardQueryTraining(learningCardQueryTraining)); cmdLearningCardQueryStart.setText(getString(R.string.learningCard_query_end)); fragmentAdapter.setQuery(learningCardQueryTraining); viewPager.setAdapter(fragmentAdapter); dialog.dismiss(); } }); dialog.show(); } else { int wrongCards = 0, rightCards = 0, firstTry = 0, secondTry = 0, thirdTry = 0; LearningCardQueryTraining reloadedTraining = MainActivity.globals.getSqLite() .getLearningCardQueryTraining("ID=" + learningCardQueryTraining.getID()).get(0); for (LearningCardQueryResult result : reloadedTraining.getResults()) { if (result.isResult1() || result.isResult2() || result.isResult3()) { rightCards++; if (result.isResult1()) { firstTry++; } else if (result.isResult2()) { secondTry++; } else { thirdTry++; } } else { wrongCards++; } } AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( LearningCardOverviewActivity.this); alertDialogBuilder.setTitle(R.string.learningCard_result); String content = String.format("%s %s%n%s %s%n%s %s%n%s %s%n%s %s%n", getString(R.string.learningCard_result_right), rightCards, getString(R.string.learningCard_result_wrong), wrongCards, getString(R.string.learningCard_result_firstTry), firstTry, getString(R.string.learningCard_result_secondTry), secondTry, getString(R.string.learningCard_result_thirdTry), thirdTry); alertDialogBuilder.setMessage(content); alertDialogBuilder.create().show(); cmdLearningCardQueryStart.setText(getString(R.string.learningCard_query)); fragmentAdapter.setQuery(null); viewPager.setAdapter(fragmentAdapter); } } }); }
From source file:nl.jalava.appostle.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mContext = getBaseContext();//from www .j a va2 s.c o m Toolbar mToolbar = (Toolbar) findViewById(R.id.app_bar); setSupportActionBar(mToolbar); // Spinner for choosing application type. Spinner spinner_app = (Spinner) findViewById(R.id.app_types); spinner_app.setVisibility(View.VISIBLE); ArrayAdapter<CharSequence> apptype = ArrayAdapter.createFromResource(mToolbar.getContext(), R.array.app_types, android.R.layout.simple_spinner_item); apptype.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner_app.setAdapter(apptype); // Select. int app_type = getSharedPreferences("AppListFragment", Context.MODE_PRIVATE) .getInt(AppListFragment.PREFS_APP_TYPE, 0); spinner_app.setSelection(app_type); spinner_app.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapter, View v, int position, long id) { AppListFragment fragment = (AppListFragment) getFragmentManager() .findFragmentById(R.id.listFragment); if (fragment != null && fragment.isVisible()) { fragment.doUpdate(position); } } @Override public void onNothingSelected(AdapterView<?> arg0) { // Not used. } }); /* mDrawer = (NavigationView) findViewById(R.id.main_drawer); mDrawer.setNavigationItemSelectedListener(this); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.drawer_open, R.string.drawer_close); mDrawerLayout.setDrawerListener(mDrawerToggle); mDrawerToggle.syncState(); mDrawerLayout.closeDrawer(GravityCompat.START); */ }
From source file:com.pgmacdesign.lacunacompanion.fragments.MailFragment.java
public void refreshMail() { JSONObject hashOptions = new JSONObject(); if (pageNum != 1) JsonParser.put(hashOptions, "page_number", pageNum); if (filterTag != "") JsonParser.put(hashOptions, "tags", filterTag); ClientSide.setContext(getActivity()); JSONObject result = ClientSide.send(new Object[] { hashOptions }, "/inbox", "view_inbox"); if (result != null) { JSONArray messages = JsonParser.getJA(result, "messages"); List<Map<String, String>> mailList = new ArrayList<Map<String, String>>(); ArrayList<String> mailIds = new ArrayList<String>(24); // Max numbers on each page is 25. boolean hasMail = false; // By default, so that there's no way to screw up. if (messages.length() > 0) { for (int i = 0; i < messages.length(); i++) { JSONObject message = JsonParser.getJO(messages, i); Map<String, String> datum = new HashMap<String, String>(2); datum.put("from", JsonParser.getS(message, "from")); datum.put("subject", JsonParser.getS(message, "subject")); mailList.add(datum);/* w ww.j av a 2s. c om*/ mailIds.add(JsonParser.getS(message, "id")); hasMail = true; } } else { Map<String, String> datum = new HashMap<String, String>(2); datum.put("from", "No new Mail available."); datum.put("subject", "Sorry. :("); mailList.add(datum); hasMail = false; } // Let the UI refresh when there's no mails. ListView mails = (ListView) getActivity().findViewById(R.id.mails); SimpleAdapter adapter = new SimpleAdapter(getActivity(), mailList, android.R.layout.simple_list_item_2, new String[] { "from", "subject" }, new int[] { android.R.id.text1, android.R.id.text2 }); mails.setAdapter(adapter); if (hasMail == true) { final Object[] MAIL_IDS = mailIds.toArray(); //spinnerReset = System.currentTimeMillis(); mails.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> a, View v, int pos, long id) { //if (System.currentTimeMillis() - spinnerReset < 1000) { //Nothing! //} //else if (System.currentTimeMillis() - spinnerReset > 1000) { String mailId = MAIL_IDS[pos].toString(); Intent intent = new Intent(getActivity(), com.pgmacdesign.lacunacompanion.module.inbox.ViewMail.class); intent.putExtra("mailId", mailId); getActivity().startActivity(intent); //} } }); // Populate the pages Spinner. ArrayAdapter<String> pagesSpinnerAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); Spinner mailPages = (Spinner) getActivity().findViewById(R.id.mailPage); double pages = (double) Math.ceil(JsonParser.getL(result, "message_count") / 25); for (int i = 1; i < pages; i++) { pagesSpinnerAdapter.add("" + i); } mailPages.setAdapter(pagesSpinnerAdapter); mailPages.recomputeViewAttributes(mailPages); mailPages.setSelection(pageNum - 1); } } }
From source file:eu.geopaparazzi.library.core.dialogs.ZoomlevelDialogFragment.java
@Override public Dialog onCreateDialog(Bundle bundle) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View labelDialogView = getActivity().getLayoutInflater().inflate(R.layout.fragment_dialog_zoomlevel, null); builder.setView(labelDialogView);/*from w w w . ja v a 2 s . c om*/ String minStr = mMinMaxZoomlevels[0] + ""; String maxStr = mMinMaxZoomlevels[1] + ""; int minIndex = 0; int maxIndex = 0; for (int i = 0; i < allZoomlevels.length; i++) { if (allZoomlevels[i].equals(minStr)) { minIndex = i; } if (allZoomlevels[i].equals(maxStr)) { maxIndex = i; } } final Spinner minSpinner = (Spinner) labelDialogView.findViewById(R.id.minZoomLevelSpinner); ArrayAdapter<String> zoomlevelSpinnerAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, allZoomlevels); zoomlevelSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); minSpinner.setAdapter(zoomlevelSpinnerAdapter); minSpinner.setSelection(minIndex); minSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Object selectedItem = minSpinner.getSelectedItem(); String fieldStr = selectedItem.toString(); mMinMaxZoomlevels[0] = Integer.parseInt(fieldStr); } public void onNothingSelected(AdapterView<?> arg0) { // ignore } }); final Spinner maxSpinner = (Spinner) labelDialogView.findViewById(R.id.maxZoomLevelSpinner); zoomlevelSpinnerAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, allZoomlevels); zoomlevelSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); maxSpinner.setAdapter(zoomlevelSpinnerAdapter); maxSpinner.setSelection(maxIndex); maxSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Object selectedItem = maxSpinner.getSelectedItem(); String fieldStr = selectedItem.toString(); mMinMaxZoomlevels[1] = Integer.parseInt(fieldStr); } public void onNothingSelected(AdapterView<?> arg0) { // ignore } }); builder.setPositiveButton(R.string.set_properties, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { if (zoomlevelPropertiesChangeListener != null) { zoomlevelPropertiesChangeListener.onPropertiesChanged(mMinMaxZoomlevels[0], mMinMaxZoomlevels[1]); } } }); builder.setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); return builder.create(); // return dialog }
From source file:com.starwood.anglerslong.LicenseAddActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle bundle = this.getIntent().getExtras(); setContentView(R.layout.license_add); Spinner s = (Spinner) findViewById(R.id.spinner); @SuppressWarnings("unchecked") ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.state_array)); s.setAdapter(adapter); s.setOnItemSelectedListener(this); isPopulated = bundle.getBoolean("isPopulated"); isArrayEmpty = bundle.getBoolean("isArrayEmpty"); if (bundle.containsKey("isEdit")) isEdit = bundle.getBoolean("isEdit"); if (bundle.containsKey("currentItemID")) currentItemID = bundle.getInt("currentItemID"); getSupportActionBar().setTitle(bundle.getString("title")); // getSupportActionBar().setSubtitle(bundle.getString("subtitle")); if (isEdit) { try {//from w w w . ja v a2 s .c o m JsonStorage jsonStorage = new JsonStorage(getApplicationContext()); String json = jsonStorage.readProfileJSON(); // Store the JSON into string JSONObject j = new JSONObject(json); JSONObject outer = j.getJSONObject("outermost"); // Outermost JSON JSONArray innerArray = outer.getJSONArray("license"); JSONObject inner = innerArray.getJSONObject(currentItemID); Spinner editSpinner = (Spinner) findViewById(R.id.spinner); editSpinner.setSelection(inner.getInt("state") + 1); // Set spinner EditText edit = (EditText) findViewById(R.id.license_name); edit.setText(inner.getString("name")); edit = (EditText) findViewById(R.id.license_number); edit.setText(inner.getString("number")); edit = (EditText) findViewById(R.id.license_type); edit.setText(inner.getString("type")); edit = (EditText) findViewById(R.id.license_issue_date); edit.setText(inner.getString("issue_date")); edit = (EditText) findViewById(R.id.license_expiration_date); edit.setText(inner.getString("exp_date")); edit = (EditText) findViewById(R.id.license_birthday); edit.setText(inner.getString("birthday")); edit = (EditText) findViewById(R.id.license_huntered); edit.setText(inner.getString("huntered")); } catch (JSONException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:eu.geopaparazzi.library.core.dialogs.LabelDialogFragment.java
@Override public Dialog onCreateDialog(Bundle bundle) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View labelDialogView = getActivity().getLayoutInflater().inflate(R.layout.fragment_dialog_label, null); builder.setView(labelDialogView);/*w w w . ja v a 2s . com*/ CheckBox visibilityCheckBox = (CheckBox) labelDialogView.findViewById(R.id.checkVisibility); visibilityCheckBox.setChecked(mCurrentLabelObject.hasLabel); visibilityCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mCurrentLabelObject.hasLabel = isChecked; } }); mSizeTextView = (TextView) labelDialogView.findViewById(R.id.sizeTextView); mSizeTextView.setText(String.valueOf(mCurrentLabelObject.labelSize)); SeekBar mSizeSeekBar = (SeekBar) labelDialogView.findViewById(R.id.sizeSeekBar); mSizeSeekBar.setOnSeekBarChangeListener(sizeChanged); mSizeSeekBar.setProgress(mCurrentLabelObject.labelSize); List<String> labelFieldsList = mCurrentLabelObject.labelFieldsList; int index = 0; for (int i = 0; i < labelFieldsList.size(); i++) { if (labelFieldsList.get(i).equals(mCurrentLabelObject.label)) { index = i; break; } } final Spinner fieldsSpinner = (Spinner) labelDialogView.findViewById(R.id.labelFieldSpinner); ArrayAdapter<String> fieldsSpinnerAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, labelFieldsList); fieldsSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); fieldsSpinner.setAdapter(fieldsSpinnerAdapter); fieldsSpinner.setSelection(index); fieldsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Object selectedItem = fieldsSpinner.getSelectedItem(); String fieldStr = selectedItem.toString(); mCurrentLabelObject.label = fieldStr; } public void onNothingSelected(AdapterView<?> arg0) { // ignore } }); builder.setPositiveButton(R.string.set_properties, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { if (labelPropertiesChangeListener != null) { labelPropertiesChangeListener.onPropertiesChanged(mCurrentLabelObject); } } }); builder.setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); return builder.create(); // return dialog }