List of usage examples for android.widget ArrayAdapter getItem
@Override public @Nullable T getItem(int position)
From source file:org.cvasilak.jboss.mobile.app.fragments.RuntimeViewFragment.java
public void showDomainHostChooser() { ProgressDialogFragment.showDialog(getActivity(), R.string.queryingServer); application.getOperationsManager().fetchDomainHostInfoInformation(new Callback() { @Override//w w w .j a va 2 s. com public void onSuccess(JsonElement reply) { JsonArray jsonArr = reply.getAsJsonArray(); // if only one host exists in the domain, // no need to display the host chooser dialog // immediately show the servers dialog for this host if (jsonArr.size() == 1) { showDomainServersDialog(jsonArr.get(0).getAsString(), false); return; } ProgressDialogFragment.dismissDialog(getActivity()); final ArrayAdapter<String> hosts = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_single_choice); // will hold the default selection host position // when the list is displayed int selPos = -1; String activeHost = application.getOperationsManager().getDomainHost(); for (int i = 0; i < jsonArr.size(); i++) { String host = jsonArr.get(i).getAsString(); if (host.equals(activeHost)) selPos = i; hosts.add(host); } AlertDialog.Builder hostsDialog = new AlertDialog.Builder(getActivity()); hostsDialog.setTitle(R.string.select_host); hostsDialog.setSingleChoiceItems(hosts, selPos, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { showDomainServersDialog(hosts.getItem(which), true); } }); hostsDialog.setPositiveButton(R.string.next, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { int selectedPosition = ((AlertDialog) dialogInterface).getListView() .getCheckedItemPosition(); showDomainServersDialog(hosts.getItem(selectedPosition), true); } }); hostsDialog.setCancelable(false); ParameterizedDialogFragment dialog = new ParameterizedDialogFragment(hostsDialog); dialog.show(getActivity().getSupportFragmentManager(), null); } @Override public void onFailure(Exception e) { ProgressDialogFragment.dismissDialog(getActivity()); ErrorDialogFragment.showDialog(getActivity(), e.getMessage()); } }); }
From source file:tw.com.geminihsu.app01.fragment.Fragment_PickUpMerchandiseStation.java
private void setLister() { timePicker = new TimePickerDialog.OnTimeSetListener() { public void onTimeSet(TimePicker view, int hourOfDay, int minute) { }/*from w w w . j av a 2 s. co m*/ }; timerPicker.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new TimePickerDialog(getActivity(), timePicker, 24, 59, true).show(); } }); departure.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builderSingle = new AlertDialog.Builder(getActivity()); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.select_dialog_item); arrayAdapter.add(getString(R.string.pop_map_option1)); arrayAdapter.add(getString(R.string.pop_map_option2)); builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String strName = arrayAdapter.getItem(which); switch (which) { case 0: Intent map = new Intent(getActivity(), OrderMapActivity.class); Bundle b = new Bundle(); b.putInt(Constants.ARG_POSITION, Constants.DEPARTURE_QUERY_GPS); map.putExtras(b); startActivityForResult(map, Constants.DEPARTURE_QUERY_GPS); break; case 1: Intent page = new Intent(getActivity(), BookmarksMapListActivity.class); Bundle flag = new Bundle(); flag.putInt(Constants.ARG_POSITION, Constants.DEPARTURE_QUERY_BOOKMARK); page.putExtras(flag); startActivityForResult(page, Constants.DEPARTURE_QUERY_BOOKMARK); break; } } }); builderSingle.show(); } }); stop.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builderSingle = new AlertDialog.Builder(getActivity()); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.select_dialog_item); arrayAdapter.add(getString(R.string.pop_map_option1)); arrayAdapter.add(getString(R.string.pop_map_option2)); builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String strName = arrayAdapter.getItem(which); switch (which) { case 0: Intent map = new Intent(getActivity(), OrderMapActivity.class); Bundle b = new Bundle(); b.putInt(Constants.ARG_POSITION, Constants.STOP_QUERY_GPS); map.putExtras(b); startActivityForResult(map, Constants.STOP_QUERY_GPS); break; case 1: Intent page = new Intent(getActivity(), BookmarksMapListActivity.class); Bundle flag = new Bundle(); flag.putInt(Constants.ARG_POSITION, Constants.STOP_QUERY_BOOKMARK); page.putExtras(flag); startActivityForResult(page, Constants.STOP_QUERY_BOOKMARK); break; } } }); builderSingle.show(); } }); destination.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builderSingle = new AlertDialog.Builder(getActivity()); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.select_dialog_item); arrayAdapter.add(getString(R.string.pop_map_option1)); arrayAdapter.add(getString(R.string.pop_map_option2)); builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String strName = arrayAdapter.getItem(which); switch (which) { case 0: Intent map = new Intent(getActivity(), OrderMapActivity.class); Bundle b = new Bundle(); b.putInt(Constants.ARG_POSITION, Constants.DESTINATION_QUERY_GPS); map.putExtras(b); startActivityForResult(map, Constants.DESTINATION_QUERY_GPS); break; case 1: Intent page = new Intent(getActivity(), BookmarksMapListActivity.class); Bundle flag = new Bundle(); flag.putInt(Constants.ARG_POSITION, Constants.DESTINATION_QUERY_BOOKMARK); page.putExtras(flag); startActivityForResult(page, Constants.DESTINATION_QUERY_BOOKMARK); break; } } }); builderSingle.show(); } }); spec.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // custom dialog final Dialog dialog = new Dialog(getActivity()); dialog.setContentView(R.layout.client_take_ride_selectspec_requirement); dialog.setTitle(getString(R.string.txt_take_spec)); Button cancel = (Button) dialog.findViewById(R.id.button_category_ok); //dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // set the custom dialog components - text, image and button ListView requirement = (ListView) dialog.findViewById(R.id.listViewDialog); getDataFromDB(); listViewAdapter = new ClientTakeRideSelectSpecListItemAdapter(getActivity(), 0, mCommentListData); requirement.setAdapter(listViewAdapter); listViewAdapter.notifyDataSetChanged(); dialog.show(); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.cancel(); } }); } }); spinner_dork_location_destination.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapter, View v, int position, long id) { currentLocation = tainStationList.get(position); destination_detail = new LocationAddress(); destination_detail.setLongitude(Double.parseDouble(currentLocation.getLng())); destination_detail.setLatitude(Double.parseDouble(currentLocation.getLat())); destination_detail.setAddress(currentLocation.getStreetAddress().substring(3, currentLocation.getStreetAddress().length())); destination_detail.setLocation(currentLocation.getLocation()); destination_detail.setZipCode(currentLocation.getStreetAddress().substring(0, 3)); destination_detail.setCountryName("Taiwan"); destination_detail.setLocality(currentLocation.getStreetAddress()); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); spinner_dork_location_departure.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapter, View v, int position, long id) { currentLocation = tainStationList.get(position); departure_detail = new LocationAddress(); departure_detail.setLongitude(Double.parseDouble(currentLocation.getLng())); departure_detail.setLatitude(Double.parseDouble(currentLocation.getLat())); departure_detail.setAddress(currentLocation.getStreetAddress().substring(3, currentLocation.getStreetAddress().length())); departure_detail.setLocation(currentLocation.getLocation()); departure_detail.setZipCode(currentLocation.getStreetAddress().substring(0, 3)); departure_detail.setCountryName("Taiwan"); departure_detail.setLocality(currentLocation.getStreetAddress()); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); }
From source file:de.uni_koblenz_landau.apow.ObsDetailFragment.java
/** * Called by settings task, when loading is finished. *///ww w .j a v a 2 s. c o m @Override public void onObsFetched(Obs obs, List<ListViewItem> testConcepts) { mObsDetailTask = null; // If result is not empty, update UI, else show error message. if (testConcepts != null) { mTestConcepts = testConcepts; ArrayAdapter<ListViewItem> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, mTestConcepts); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mTestConceptView.setAdapter(adapter); if (obs != null) { mObs = obs; // Observation is question. if (mObs.getConcept().getConceptId() == Constants.QUESTION_CONCEPT_ID) { mQuestionTextView.setText(mObs.getValueText()); // Observation is test. } else if (mObs.getConcept().getConceptClass().getConceptClassId() == Constants.TEST_CLASS_ID) { mTestValueView.setText("" + mObs.getValueNumeric()); mTestUnitView.setText(((ConceptNumeric) mObs.getConcept()).getUnits()); int position = -1; for (int i = 0; i < adapter.getCount(); i++) { if (adapter.getItem(i).getId() == mObs.getConcept().getConceptId()) { position = i; break; } } mTestConceptView.setSelection(position); // Observation is finding. } else if (mObs.getConcept().getConceptId() == Constants.FINDING_SET_CONCEPT_ID) { for (Obs obs1 : mObs.getGroupMembers()) { if (obs1.getConcept().getConceptId() == Constants.FINDING_CONCEPT) { mFindingValueCodedView.setText(obs1.getValueCoded().getName().getName()); findingCode = obs1.getValueCoded().getConceptId(); } if (obs1.getConcept().getConceptId() == Constants.FINDING_CERTAINTY && obs1.getValueCoded().getConceptId() == Constants.FINDING_CERTAINTY_CONFIRMED) { mFindingCertaintyView.setChecked(true); } if (obs1.getConcept().getConceptId() == Constants.FINDING_SEVERITY && obs1.getValueCoded().getConceptId() == Constants.FINDING_SEVERITY_PRIMARY) { mFindingSeverityCodedView.setChecked(true); } } // Observation is symptom. } else if (mObs.getConcept().getConceptClass() .getConceptClassId() == Constants.SYMPTOM_CONCEPT_CLASS_ID) { mSymptomValueView.setText(mObs.getConcept().getName().getName()); symptomCode = mObs.getConcept().getConceptId(); } } else { mObs = new Obs(); mObs.setEncounter(new Encounter(mEncounterID)); } restoreView(); } else { Toast.makeText(getActivity(), R.string.error_database, Toast.LENGTH_SHORT).show(); } }
From source file:org.openremote.android.console.AppSettingsActivity.java
/** * Auto discovery servers and add them in a list view. * Click a list item and make it as current server. * // w w w.j a v a 2s . c om * @return the list view */ private ListView constructAutoServersView() { final ListView lv = new ListView(this); lv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 200)); lv.setPadding(20, 5, 5, 10); lv.setBackgroundColor(0); lv.setCacheColorHint(0); lv.setItemsCanFocus(true); lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); final ArrayAdapter<String> serverListAdapter = new ArrayAdapter<String>(appSettingsView.getContext(), R.layout.server_list_item, new ArrayList<String>()); lv.setAdapter(serverListAdapter); new IPAutoDiscoveryServer() { @Override protected void onProgressUpdate(Void... values) { if (progressLayout != null) { progressLayout.setVisibility(View.VISIBLE); } } @Override protected void onPostExecute(List<String> result) { int length = result.size(); for (int i = 0; i < length; i++) { serverListAdapter.add(result.get(i)); } if (length > 0) { lv.setItemChecked(0, true); currentServer = serverListAdapter.getItem(0); AppSettingsModel.setCurrentServer(AppSettingsActivity.this, currentServer); } if (progressLayout != null) { progressLayout.setVisibility(View.INVISIBLE); } requestPanelList(); checkAuthentication(); requestAccess(); } }.execute((Void) null); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { currentServer = (String) parent.getItemAtPosition(position); AppSettingsModel.setCurrentServer(AppSettingsActivity.this, currentServer); requestPanelList(); checkAuthentication(); requestAccess(); } }); return lv; }
From source file:tw.com.geminihsu.app01.fragment.Fragment_PickUpAirPlane.java
private void setLister() { timePicker = new TimePickerDialog.OnTimeSetListener() { public void onTimeSet(TimePicker view, int hourOfDay, int minute) { }// w ww.jav a 2s .c om }; timerPicker.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new TimePickerDialog(getActivity(), timePicker, 24, 59, true).show(); } }); departure.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builderSingle = new AlertDialog.Builder(getActivity()); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.select_dialog_item); arrayAdapter.add(getString(R.string.pop_map_option1)); arrayAdapter.add(getString(R.string.pop_map_option2)); builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String strName = arrayAdapter.getItem(which); switch (which) { case 0: Intent map = new Intent(getActivity(), OrderMapActivity.class); Bundle b = new Bundle(); b.putInt(Constants.ARG_POSITION, Constants.DEPARTURE_QUERY_GPS); map.putExtras(b); startActivityForResult(map, Constants.DEPARTURE_QUERY_GPS); break; case 1: Intent page = new Intent(getActivity(), BookmarksMapListActivity.class); Bundle flag = new Bundle(); flag.putInt(Constants.ARG_POSITION, Constants.DEPARTURE_QUERY_BOOKMARK); page.putExtras(flag); startActivityForResult(page, Constants.DEPARTURE_QUERY_BOOKMARK); break; } } }); builderSingle.show(); } }); stop.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builderSingle = new AlertDialog.Builder(getActivity()); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.select_dialog_item); arrayAdapter.add(getString(R.string.pop_map_option1)); arrayAdapter.add(getString(R.string.pop_map_option2)); builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String strName = arrayAdapter.getItem(which); switch (which) { case 0: Intent map = new Intent(getActivity(), OrderMapActivity.class); Bundle b = new Bundle(); b.putInt(Constants.ARG_POSITION, Constants.STOP_QUERY_GPS); map.putExtras(b); startActivityForResult(map, Constants.STOP_QUERY_GPS); break; case 1: Intent page = new Intent(getActivity(), BookmarksMapListActivity.class); Bundle flag = new Bundle(); flag.putInt(Constants.ARG_POSITION, Constants.STOP_QUERY_GPS); page.putExtras(flag); startActivityForResult(page, Constants.STOP_QUERY_BOOKMARK); break; } } }); builderSingle.show(); } }); destination.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builderSingle = new AlertDialog.Builder(getActivity()); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.select_dialog_item); arrayAdapter.add(getString(R.string.pop_map_option1)); arrayAdapter.add(getString(R.string.pop_map_option2)); builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String strName = arrayAdapter.getItem(which); switch (which) { case 0: Intent map = new Intent(getActivity(), OrderMapActivity.class); Bundle b = new Bundle(); b.putInt(Constants.ARG_POSITION, Constants.DESTINATION_QUERY_GPS); map.putExtras(b); startActivityForResult(map, Constants.DESTINATION_QUERY_GPS); break; case 1: Intent page = new Intent(getActivity(), BookmarksMapListActivity.class); Bundle flag = new Bundle(); flag.putInt(Constants.ARG_POSITION, Constants.DESTINATION_QUERY_GPS); page.putExtras(flag); startActivityForResult(page, Constants.DESTINATION_QUERY_BOOKMARK); break; } } }); builderSingle.show(); } }); getDataFromDB(); linearLayout_spec.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // custom dialog final Dialog dialog = new Dialog(getActivity()); dialog.setContentView(R.layout.client_take_ride_selectspec_requirement); dialog.setTitle(getString(R.string.txt_take_spec)); Button cancel = (Button) dialog.findViewById(R.id.button_category_cancel); Button ok = (Button) dialog.findViewById(R.id.button_category_ok); //dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // set the custom dialog components - text, image and button ListView requirement = (ListView) dialog.findViewById(R.id.listViewDialog); requirement.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { ClientTakeRideSelectSpecListItem item = mCommentListData.get(position); item.check = !item.check; mCommentListData.set(position, item); listViewAdapter.notifyDataSetChanged(); } }); if (listViewAdapter == null) { listViewAdapter = new ClientTakeRideSelectSpecListItemAdapter(getActivity(), 0, mCommentListData); } requirement.setAdapter(listViewAdapter); listViewAdapter.notifyDataSetChanged(); dialog.show(); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.cancel(); } }); String require; ok.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String require = ""; for (ClientTakeRideSelectSpecListItem item : mCommentListData) { if (item.check) { spec_list.add(item); require += item.book_title + ","; } } if (!require.isEmpty()) require = require.substring(0, require.length() - 1); spec_value.setText(require); dialog.cancel(); } }); } }); spec.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // custom dialog final Dialog dialog = new Dialog(getActivity()); dialog.setContentView(R.layout.client_take_ride_selectspec_requirement); dialog.setTitle(getString(R.string.txt_take_spec)); Button cancel = (Button) dialog.findViewById(R.id.button_category_ok); //dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // set the custom dialog components - text, image and button ListView requirement = (ListView) dialog.findViewById(R.id.listViewDialog); getDataFromDB(); listViewAdapter = new ClientTakeRideSelectSpecListItemAdapter(getActivity(), 0, mCommentListData); requirement.setAdapter(listViewAdapter); listViewAdapter.notifyDataSetChanged(); dialog.show(); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.cancel(); } }); } }); spinner_airport_location_destination.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapter, View v, int position, long id) { currentLocation = tainStationList.get(position); destination_detail = new LocationAddress(); destination_detail.setLongitude(Double.parseDouble(currentLocation.getLng())); destination_detail.setLatitude(Double.parseDouble(currentLocation.getLat())); destination_detail.setAddress(currentLocation.getStreetAddress().substring(3, currentLocation.getStreetAddress().length())); destination_detail.setLocation(currentLocation.getLocation()); String zipCode = (getTrainStationZip(currentLocation.getLocation())); destination_detail.setZipCode(zipCode); destination_detail.setCountryName("Taiwan"); destination_detail.setLocality(currentLocation.getStreetAddress()); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); spinner_airport_location_departure.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapter, View v, int position, long id) { currentLocation = tainStationList.get(position); departure_detail = new LocationAddress(); departure_detail.setLongitude(Double.parseDouble(currentLocation.getLng())); departure_detail.setLatitude(Double.parseDouble(currentLocation.getLat())); departure_detail.setAddress(currentLocation.getStreetAddress().substring(3, currentLocation.getStreetAddress().length())); departure_detail.setLocation(currentLocation.getLocation()); //departure_detail.setZipCode(currentLocation.getStreetAddress().substring(0,3)); String zipCode = (getTrainStationZip(currentLocation.getLocation())); departure_detail.setZipCode(zipCode); departure_detail.setCountryName("Taiwan"); departure_detail.setLocality(currentLocation.getStreetAddress()); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); }
From source file:com.silentcircle.contacts.interactions.ImportExportDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Wrap our context to inflate list items using the correct theme final Resources res = getActivity().getResources(); final LayoutInflater dialogInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final boolean contactsAreAvailable = getArguments().getBoolean(ARG_CONTACTS_ARE_AVAILABLE); // Adapter that shows a list of string resources final ArrayAdapter<Integer> adapter = new ArrayAdapter<Integer>(getActivity(), R.layout.select_dialog_item) { @Override// ww w. j av a 2 s . co m public View getView(int position, View convertView, ViewGroup parent) { final TextView result = (TextView) (convertView != null ? convertView : dialogInflater.inflate(R.layout.select_dialog_item, parent, false)); final int resId = getItem(position); result.setText(resId); return result; } }; // if (TelephonyManager.getDefault().hasIccCard() // && res.getBoolean(R.bool.config_allow_sim_import)) { // adapter.add(R.string.import_from_sim); // } if (res.getBoolean(R.bool.config_allow_import_from_sdcard)) { adapter.add(R.string.import_from_sdcard); } if (res.getBoolean(R.bool.config_allow_export_to_sdcard)) { if (contactsAreAvailable) { adapter.add(R.string.export_to_sdcard); } } if (res.getBoolean(R.bool.config_allow_share_visible_contacts)) { if (contactsAreAvailable) { adapter.add(R.string.share_visible_contacts); } } final DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { boolean dismissDialog; final int resId = adapter.getItem(which); switch (resId) { // case R.string.import_from_sim: case R.string.import_from_sdcard: { dismissDialog = handleImportRequest(resId); break; } case R.string.export_to_sdcard: { dismissDialog = true; Intent exportIntent = new Intent(getActivity(), ExportVCardActivity.class); getActivity().startActivity(exportIntent); break; } // case R.string.share_visible_contacts: { // dismissDialog = true; // Log.e(TAG, "Share contects not yet available"); // doShareVisibleContacts(); // break; // } default: { dismissDialog = true; Log.e(TAG, "Unexpected resource: " + getActivity().getResources().getResourceEntryName(resId)); } } if (dismissDialog) { dialog.dismiss(); } } }; return new AlertDialog.Builder(getActivity()) .setTitle(contactsAreAvailable ? R.string.dialog_import_export : R.string.dialog_import) .setSingleChoiceItems(adapter, -1, clickListener).create(); }
From source file:org.gots.ui.NewSeedActivity.java
/** * *//*from www. jav a2 s .c om*/ private void initVarietyList() { LocalSeedProvider helper = new LocalSeedProvider(getApplicationContext()); String[] referenceList = null; if (newSeed.getSpecie() != null) referenceList = helper.getArrayVarietyBySpecie(newSeed.getSpecie()); else referenceList = helper.getArrayVariety(); final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, referenceList); autoCompleteVariety.setAdapter(adapter); autoCompleteVariety.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { String variety = autoCompleteVariety.getText().toString(); newSeed.setVariety(variety); seedWidgetLong.setSeed(newSeed); seedWidgetLong.invalidate(); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { } }); autoCompleteVariety.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { String variety = adapter.getItem(arg2); newSeed.setVariety(variety); seedWidgetLong.setSeed(newSeed); seedWidgetLong.invalidate(); } }); autoCompleteVariety.invalidate(); }
From source file:com.eugene.fithealthmaingit.UI.NavFragments.FragmentJournalMainHome.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); int menuItemIndex = item.getItemId(); contextListPosition = info.position; AlertDialog.Builder builderSingle = new AlertDialog.Builder(getActivity()).setTitle("Move Meal To:"); final ArrayAdapter<String> mAdapterMoveMeal = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1); mAdapterMoveMeal.add("Snack"); mAdapterMoveMeal.add("Breakfast"); mAdapterMoveMeal.add("Lunch"); mAdapterMoveMeal.add("Dinner"); builderSingle.setNegativeButton("cancel", new DialogInterface.OnClickListener() { @Override//from www . j av a 2 s.c o m public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builderSingle.setAdapter(mAdapterMoveMeal, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String strName = mAdapterMoveMeal.getItem(which); if (contextListChoice == 1) { LogMeal logMeals = mLogSnackAdapter.getItem(contextListPosition); logMeals.setMealChoice(strName); logMeals.edit(); initializeAdapters(mDate); } if (contextListChoice == 2) { LogMeal logMeals = mLogBreakfastAdapter.getItem(contextListPosition); logMeals.setMealChoice(strName); logMeals.edit(); initializeAdapters(mDate); } if (contextListChoice == 3) { LogMeal logMeals = mLogLunchAdapter.getItem(contextListPosition); logMeals.setMealChoice(strName); logMeals.edit(); initializeAdapters(mDate); } if (contextListChoice == 4) { LogMeal logMeals = mLogDinnerAdapter.getItem(contextListPosition); logMeals.setMealChoice(strName); logMeals.edit(); initializeAdapters(mDate); } updateListViews(); } }); switch (contextListChoice) { case 1: switch (menuItemIndex) { case 0: LogMeal logMeals = mLogSnackAdapter.getItem(contextListPosition); logMeals.delete(); mLogSnackAdapter.remove(logMeals); mLogSnackAdapter.notifyDataSetChanged(); testing(); initializeAdapters(new Date()); refreshOnDelete(); updateListViews(); equations(); break; case 1: builderSingle.show(); break; } break; case 2: switch (menuItemIndex) { case 0: LogMeal logMeals = mLogBreakfastAdapter.getItem(contextListPosition); logMeals.delete(); mLogBreakfastAdapter.remove(logMeals); mLogBreakfastAdapter.notifyDataSetChanged(); testing(); initializeAdapters(new Date()); refreshOnDelete(); updateListViews(); equations(); break; case 1: builderSingle.show(); break; } break; case 3: switch (menuItemIndex) { case 0: LogMeal logMeals = mLogLunchAdapter.getItem(contextListPosition); logMeals.delete(); mLogLunchAdapter.remove(logMeals); mLogLunchAdapter.notifyDataSetChanged(); testing(); initializeAdapters(new Date()); refreshOnDelete(); updateListViews(); equations(); break; case 1: builderSingle.show(); break; } break; case 4: switch (menuItemIndex) { case 0: LogMeal logMeals = mLogDinnerAdapter.getItem(contextListPosition); logMeals.delete(); mLogDinnerAdapter.remove(logMeals); mLogDinnerAdapter.notifyDataSetChanged(); testing(); initializeAdapters(new Date()); refreshOnDelete(); updateListViews(); equations(); break; case 1: builderSingle.show(); break; } break; default: break; } return true; }
From source file:com.microsoft.windowsazure.mobileservices.zumoe2etestapp.MainActivity.java
@SuppressWarnings("unchecked") private void refreshTestGroupsAndLog() { mLog = new StringBuilder(); Thread thread = new Thread() { @Override/*w w w. j ava2 s . com*/ public void run() { final boolean isNetBackend = IsNetBackend(); runOnUiThread(new Runnable() { @Override public void run() { ArrayAdapter<TestGroup> adapter = (ArrayAdapter<TestGroup>) mTestGroupSpinner.getAdapter(); adapter.clear(); adapter.add(new RoundTripTests()); adapter.add(new QueryTests()); adapter.add(new UpdateDeleteTests()); //adapter.add(new ClientSDKLoginTests()); adapter.add(new LoginTests(isNetBackend)); adapter.add(new MiscTests()); // adapter.add(new PushTests()); adapter.add(new CustomApiTests()); adapter.add(new SystemPropertiesTests(isNetBackend)); adapter.add(new EnhancedPushTests(isNetBackend)); adapter.add(new OfflineTests()); ArrayList<Pair<TestCase, String>> allTests = new ArrayList<Pair<TestCase, String>>(); ArrayList<Pair<TestCase, String>> allUnattendedTests = new ArrayList<Pair<TestCase, String>>(); for (int i = 0; i < adapter.getCount(); i++) { TestGroup group = adapter.getItem(i); allTests.add(new Pair<TestCase, String>( Util.createSeparatorTest("Start of group: " + group.getName()), "Separator")); allUnattendedTests.add(new Pair<TestCase, String>( Util.createSeparatorTest("Start of group: " + group.getName()), "Separator")); List<TestCase> testsForGroup = group.getTestCases(); for (TestCase test : testsForGroup) { allTests.add(new Pair<TestCase, String>(test, group.getName())); if (test.canRunUnattended()) { allUnattendedTests.add(new Pair<TestCase, String>(test, group.getName())); } } allTests.add(new Pair<TestCase, String>( Util.createSeparatorTest("----" + group.getName() + "----"), "Separator")); allUnattendedTests.add(new Pair<TestCase, String>( Util.createSeparatorTest("----" + group.getName() + "----"), "Separator")); } int unattendedTestsIndex = adapter.getCount(); adapter.add( new CompositeTestGroup(TestGroup.AllUnattendedTestsGroupName, allUnattendedTests)); adapter.add(new CompositeTestGroup(TestGroup.AllTestsGroupName, allTests)); if (shouldRunUnattended()) { mTestGroupSpinner.setSelection(unattendedTestsIndex); selectTestGroup(unattendedTestsIndex); changeCheckAllTests(true); runTests(); } else { mTestGroupSpinner.setSelection(0); selectTestGroup(0); } } }); } }; thread.start(); }
From source file:com.nttec.everychan.ui.NewTabFragment.java
private void openChansList() { final ArrayAdapter<ChanModule> chansAdapter = new ArrayAdapter<ChanModule>(activity, 0) { private LayoutInflater inflater = LayoutInflater.from(activity); private int drawablePadding = (int) (resources.getDisplayMetrics().density * 5 + 0.5f); {/*from w ww. j ava 2s . co m*/ for (ChanModule chan : MainApplication.getInstance().chanModulesList) add(chan); } @Override public View getView(int position, View convertView, ViewGroup parent) { ChanModule chan = getItem(position); TextView view = (TextView) (convertView == null ? inflater.inflate(android.R.layout.simple_list_item_1, parent, false) : convertView); view.setText(chan.getDisplayingName()); view.setCompoundDrawablesWithIntrinsicBounds(chan.getChanFavicon(), null, null, null); view.setCompoundDrawablePadding(drawablePadding); return view; } }; DialogInterface.OnClickListener onChanSelected = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ChanModule chan = chansAdapter.getItem(which); UrlPageModel model = new UrlPageModel(); model.chanName = chan.getChanName(); model.type = UrlPageModel.TYPE_INDEXPAGE; openNewTab(chan.buildUrl(model)); } }; final AlertDialog chansListDialog = new AlertDialog.Builder(activity) .setTitle(R.string.newtab_quickaccess_all_boards).setAdapter(chansAdapter, onChanSelected) .setNegativeButton(android.R.string.cancel, null).create(); chansListDialog.getListView().setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { MenuItem.OnMenuItemClickListener contextMenuHandler = new MenuItem.OnMenuItemClickListener() { @SuppressLint("InlinedApi") @Override public boolean onMenuItemClick(MenuItem item) { final ChanModule chan = chansAdapter .getItem(((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position); switch (item.getItemId()) { case R.id.context_menu_favorites_from_fragment: if (MainApplication.getInstance().database.isFavorite(chan.getChanName(), null, null, null)) { MainApplication.getInstance().database.removeFavorite(chan.getChanName(), null, null, null); } else { try { UrlPageModel indexPage = new UrlPageModel(); indexPage.chanName = chan.getChanName(); indexPage.type = UrlPageModel.TYPE_INDEXPAGE; MainApplication.getInstance().database.addFavorite(chan.getChanName(), null, null, null, chan.getChanName(), chan.buildUrl(indexPage)); } catch (Exception e) { Logger.e(TAG, e); } } return true; case R.id.context_menu_quickaccess_add: QuickAccess.Entry newEntry = new QuickAccess.Entry(); newEntry.chan = chan; list.add(0, newEntry); adapter.notifyDataSetChanged(); saveQuickAccessToPreferences(); chansListDialog.dismiss(); return true; case R.id.context_menu_quickaccess_custom_board: LinearLayout dialogLayout = new LinearLayout(activity); dialogLayout.setOrientation(LinearLayout.VERTICAL); final EditText boardField = new EditText(activity); final EditText descriptionField = new EditText(activity); boardField.setHint(R.string.newtab_quickaccess_addcustom_boardcode); descriptionField.setHint(R.string.newtab_quickaccess_addcustom_boarddesc); LinearLayout.LayoutParams fieldsParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); dialogLayout.addView(boardField, fieldsParams); dialogLayout.addView(descriptionField, fieldsParams); DialogInterface.OnClickListener onOkClicked = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String boardName = boardField.getText().toString(); for (QuickAccess.Entry entry : list) if (entry.boardName != null && entry.chan != null) if (entry.chan.getChanName().equals(chan.getChanName()) && entry.boardName.equals(boardName)) { Toast.makeText(activity, R.string.newtab_quickaccess_addcustom_already_exists, Toast.LENGTH_LONG).show(); return; } try { if (boardName.trim().length() == 0) throw new Exception(); UrlPageModel boardPageModel = new UrlPageModel(); boardPageModel.type = UrlPageModel.TYPE_BOARDPAGE; boardPageModel.chanName = chan.getChanName(); boardPageModel.boardName = boardName; boardPageModel.boardPage = UrlPageModel.DEFAULT_FIRST_PAGE; chan.buildUrl(boardPageModel); //, ?? ? } catch (Exception e) { Toast.makeText(activity, R.string.newtab_quickaccess_addcustom_incorrect_code, Toast.LENGTH_LONG).show(); return; } QuickAccess.Entry newEntry = new QuickAccess.Entry(); newEntry.chan = chan; newEntry.boardName = boardName; newEntry.boardDescription = descriptionField.getText().toString(); list.add(0, newEntry); adapter.notifyDataSetChanged(); saveQuickAccessToPreferences(); chansListDialog.dismiss(); } }; new AlertDialog.Builder(activity) .setTitle(resources.getString(R.string.newtab_quickaccess_addcustom_title, chan.getChanName())) .setView(dialogLayout).setPositiveButton(android.R.string.ok, onOkClicked) .setNegativeButton(android.R.string.cancel, null).show(); return true; } return false; } }; String thisChanName = chansAdapter.getItem(((AdapterView.AdapterContextMenuInfo) menuInfo).position) .getChanName(); boolean canAddToQuickAccess = true; for (QuickAccess.Entry entry : list) if (entry.boardName == null && entry.chan != null && entry.chan.getChanName().equals(thisChanName)) { canAddToQuickAccess = false; break; } menu.add(Menu.NONE, R.id.context_menu_favorites_from_fragment, 1, MainApplication.getInstance().database.isFavorite(thisChanName, null, null, null) ? R.string.context_menu_remove_favorites : R.string.context_menu_add_favorites) .setOnMenuItemClickListener(contextMenuHandler); menu.add(Menu.NONE, R.id.context_menu_quickaccess_add, 2, R.string.context_menu_quickaccess_add) .setOnMenuItemClickListener(contextMenuHandler).setVisible(canAddToQuickAccess); menu.add(Menu.NONE, R.id.context_menu_quickaccess_custom_board, 3, R.string.context_menu_quickaccess_custom_board) .setOnMenuItemClickListener(contextMenuHandler); if (isSingleboardChan( chansAdapter.getItem(((AdapterView.AdapterContextMenuInfo) menuInfo).position))) menu.findItem(R.id.context_menu_quickaccess_custom_board).setVisible(false); } }); chansListDialog.show(); }