List of usage examples for android.widget Spinner getCount
@Override public int getCount()
From source file:com.nextgis.mobile.forms.DescriptionFragment.java
public void onStoreValues() { if (getView() != null) { InputPointActivity activity = (InputPointActivity) getActivity(); if (activity == null) return; Spinner spinner_cat = (Spinner) getView().findViewById(R.id.spinner_cat); Spinner spinner_subcat = (Spinner) getView().findViewById(R.id.spinner_subcat); TextView textview = (TextView) getView().findViewById(R.id.spinner_subcat_custom); Object obj = spinner_cat.getSelectedItem(); if (obj == null) return; String sCat = spinner_cat.getSelectedItem().toString(); if (sCat.length() == 0) return; String sSubCat;//from www .j a v a 2 s . c o m if (sCat.equalsIgnoreCase("custom")) { sSubCat = textview.getText().toString(); } else { if (spinner_subcat.getCount() > 0) { sSubCat = spinner_subcat.getSelectedItem().toString(); } else { sSubCat = getView().getResources().getString(R.string.input_poi_subcatdefault); } } activity.SetDescription(sCat, sSubCat); } }
From source file:org.rapidandroid.activity.FormCreator.java
/** * Gets called from onActivityResult//from w w w . j a va 2 s .c o m * * @param f */ private void restoreForm(Form f) { EditText etxFormName = (EditText) findViewById(R.id.etx_formname); etxFormName.setText(f.getFormName()); EditText etxFormPrefix = (EditText) findViewById(R.id.etx_formprefix); etxFormPrefix.setText(f.getPrefix()); EditText etxDescription = (EditText) findViewById(R.id.etx_description); etxDescription.setText(f.getDescription()); Spinner spin_forms = (Spinner) findViewById(R.id.spinner_formparser); int cnt = spin_forms.getCount(); for (int i = 0; i < cnt; i++) { if (spin_forms.getItemAtPosition(i).toString().toLowerCase(Locale.getDefault()) .contains(f.getParserType().name().toLowerCase(Locale.getDefault()))) spin_forms.setSelection(i); } // add fields Field[] fields = f.getFields(); Arrays.sort(fields, new Comparator<Field>() { public int compare(Field f1, Field f2) { if (f1.getSequenceId() < f2.getSequenceId()) return -1; else if (f1.getSequenceId() > f2.getSequenceId()) return 1; return 0; } }); for (Field fi : fields) { Bundle b = new Bundle(); b.putString(ResultConstants.RESULT_KEY_FIELDNAME, fi.getName()); b.putString(ResultConstants.RESULT_KEY_DESCRIPTION, fi.getDescription()); b.putInt(ResultConstants.RESULT_KEY_FIELDTYPE_ID, ((SimpleFieldType) fi.getFieldType()).getId()); addNewFieldFromActivity(b); } // save state so that the "current_form" is in the intent // and will therefore be loaded in the onResume call saveState(); }
From source file:com.google.sample.beaconservice.ManageBeaconFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_manage_beacon, container, false); advertisedId_Type = (TextView) rootView.findViewById(R.id.advertisedId_Type); advertisedId_Id = (TextView) rootView.findViewById(R.id.advertisedId_Id); status = (TextView) rootView.findViewById(R.id.status); placeId = (TextView) rootView.findViewById(R.id.placeId); placeId.setOnClickListener(new View.OnClickListener() { @Override/*from w ww .j av a 2 s . co m*/ public void onClick(View v) { editLatLngAction(); } }); latLng = (TextView) rootView.findViewById(R.id.latLng); latLng.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { editLatLngAction(); } }); mapView = (ImageView) rootView.findViewById(R.id.mapView); mapView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { editLatLngAction(); } }); expectedStability = (TextView) rootView.findViewById(R.id.expectedStability); expectedStability.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle("Edit Stability"); final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.stability_enums, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); final Spinner spinner = new Spinner(getActivity()); spinner.setAdapter(adapter); // Set the position of the spinner to the current value. if (beacon.expectedStability != null && !beacon.expectedStability.equals(Beacon.STABILITY_UNSPECIFIED)) { for (int i = 0; i < spinner.getCount(); i++) { if (beacon.expectedStability.equals(spinner.getItemAtPosition(i))) { spinner.setSelection(i); } } } builder.setView(spinner); builder.setPositiveButton("Save", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { beacon.expectedStability = (String) spinner.getSelectedItem(); updateBeacon(); dialog.dismiss(); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.show(); } }); description = (TextView) rootView.findViewById(R.id.description); description.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle("Edit description"); final EditText editText = new EditText(getActivity()); editText.setText(description.getText()); builder.setView(editText); builder.setPositiveButton("Save", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { beacon.description = editText.getText().toString(); updateBeacon(); dialog.dismiss(); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.show(); } }); actionButton = (Button) rootView.findViewById(R.id.actionButton); decommissionButton = (Button) rootView.findViewById(R.id.decommissionButton); decommissionButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new AlertDialog.Builder(getActivity()).setTitle("Decommission Beacon") .setMessage("Are you sure you want to decommission this beacon? This operation is " + "irreversible and the beacon cannot be registered again") .setPositiveButton("Decommission", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Callback decommissionCallback = new Callback() { @Override public void onFailure(Request request, IOException e) { logErrorAndToast("Failed request: " + request, e); } @Override public void onResponse(Response response) throws IOException { if (response.isSuccessful()) { beacon.status = Beacon.STATUS_DECOMMISSIONED; updateBeacon(); } else { String body = response.body().string(); logErrorAndToast("Unsuccessful decommissionBeacon request: " + body); } } }; client.decommissionBeacon(decommissionCallback, beacon.getBeaconName()); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).show(); } }); attachmentsDivider = rootView.findViewById(R.id.attachmentsDivider); attachmentsLabel = (TextView) rootView.findViewById(R.id.attachmentsLabel); attachmentsTable = (TableLayout) rootView.findViewById(R.id.attachmentsTableLayout); // Fetch the namespace for the developer console project ID. We redraw the UI once that // request completes. // TODO: cache this. Callback listNamespacesCallback = new Callback() { @Override public void onFailure(Request request, IOException e) { logErrorAndToast("Failed request: " + request, e); } @Override public void onResponse(Response response) throws IOException { String body = response.body().string(); if (response.isSuccessful()) { try { JSONObject json = new JSONObject(body); JSONArray namespaces = json.getJSONArray("namespaces"); // At present there can be only one namespace. String tmp = namespaces.getJSONObject(0).getString("namespaceName"); if (tmp.startsWith("namespaces/")) { namespace = tmp.substring("namespaces/".length()); } else { namespace = tmp; } redraw(); } catch (JSONException e) { Log.e(TAG, "JSONException", e); } } else { logErrorAndToast("Unsuccessful listNamespaces request: " + body); } } }; client.listNamespaces(listNamespacesCallback); return rootView; }
From source file:edu.cmu.hcii.hangg.beeksbeacon.Fragments.ManageBeaconFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.i(TAG, "bi.id: " + beaconInstance.id + ", bi.googleType: " + beaconInstance.googleType); View rootView = inflater.inflate(R.layout.fragment_manage_beacon, container, false); advertisedId_Type = (TextView) rootView.findViewById(R.id.advertisedId_Type); advertisedId_Id = (TextView) rootView.findViewById(R.id.advertisedId_Id); status = (TextView) rootView.findViewById(R.id.status); placeId = (TextView) rootView.findViewById(R.id.placeId); placeId.setOnClickListener(new View.OnClickListener() { @Override/* w w w . j a v a 2s . co m*/ public void onClick(View v) { editLatLngAction(); } }); latLng = (TextView) rootView.findViewById(R.id.latLng); latLng.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { editLatLngAction(); } }); mapView = (ImageView) rootView.findViewById(R.id.mapView); mapView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { editLatLngAction(); } }); expectedStability = (TextView) rootView.findViewById(R.id.expectedStability); expectedStability.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle("Edit Stability"); final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.stability_enums, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); final Spinner spinner = new Spinner(getActivity()); spinner.setAdapter(adapter); // Set the position of the spinner to the current value. if (beaconInstance.expectedStability != null && !beaconInstance.expectedStability.equals(BeaconInstance.STABILITY_UNSPECIFIED)) { for (int i = 0; i < spinner.getCount(); i++) { if (beaconInstance.expectedStability.equals(spinner.getItemAtPosition(i))) { spinner.setSelection(i); } } } builder.setView(spinner); builder.setPositiveButton("Save", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { beaconInstance.expectedStability = (String) spinner.getSelectedItem(); updateBeacon(); dialog.dismiss(); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.show(); } }); description = (TextView) rootView.findViewById(R.id.description); description.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle("Edit description"); final EditText editText = new EditText(getActivity()); editText.setText(description.getText()); builder.setView(editText); builder.setPositiveButton("Save", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { beaconInstance.description = editText.getText().toString(); updateBeacon(); dialog.dismiss(); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.show(); } }); actionButton = (Button) rootView.findViewById(R.id.actionButton); decommissionButton = (Button) rootView.findViewById(R.id.decommissionButton); decommissionButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new AlertDialog.Builder(getActivity()).setTitle("Decommission Beacon") .setMessage("Are you sure you want to decommission this beacon? This operation is " + "irreversible and the beacon cannot be registered again") .setPositiveButton("Decommission", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Callback decommissionCallback = new Callback() { @Override public void onFailure(Request request, IOException e) { logErrorAndToast("Failed request: " + request, e); } @Override public void onResponse(Response response) throws IOException { if (response.isSuccessful()) { beaconInstance.status = BeaconInstance.STATUS_DECOMMISSIONED; updateBeacon(); } else { String body = response.body().string(); logErrorAndToast("Unsuccessful decommissionBeacon request: " + body); } } }; client.decommissionBeacon(decommissionCallback, beaconInstance.getBeaconName()); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).show(); } }); attachmentsDivider = rootView.findViewById(R.id.attachmentsDivider); attachmentsLabel = (TextView) rootView.findViewById(R.id.attachmentsLabel); attachmentsTable = (TableLayout) rootView.findViewById(R.id.attachmentsTableLayout); // Fetch the namespace for the developer console project ID. We redraw the UI once that // request completes. // TODO: cache this. Callback listNamespacesCallback = new Callback() { @Override public void onFailure(Request request, IOException e) { logErrorAndToast("Failed request: " + request, e); } @Override public void onResponse(Response response) throws IOException { String body = response.body().string(); if (response.isSuccessful()) { try { JSONObject json = new JSONObject(body); JSONArray namespaces = json.getJSONArray("namespaces"); // At present there can be only one namespace. String tmp = namespaces.getJSONObject(0).getString("namespaceName"); if (tmp.startsWith("namespaces/")) { namespace = tmp.substring("namespaces/".length()); } else { namespace = tmp; } redraw(); } catch (JSONException e) { Log.e(TAG, "JSONException", e); } } else { logErrorAndToast("Unsuccessful listNamespaces request: " + body); } } }; client.listNamespaces(listNamespacesCallback); return rootView; }
From source file:com.bai.android.ui.OtherActivity.java
/** Selects a String value in a spinner if the spinner contains that value. */ private void selectSpinnerItem(Spinner targetSpinner, String searchValue) { // if the user doesn't have an assigned value - don't select anything if (searchValue == null) { return;//ww w.j ava 2 s .c o m } // find the position of the value in the spinner int position = -1; for (int i = 0; i < targetSpinner.getCount(); i++) { if (searchValue.equals(targetSpinner.getItemAtPosition(i))) { position = i; break; } } // select the value in the spinner if (position != -1) { targetSpinner.setSelection(position); } }
From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java
private static int getIndexofSpinner(Spinner spinner, String myString) { int index = 0; for (int i = 0; i < spinner.getCount(); i++) { if (spinner.getItemAtPosition(i).toString().equals(myString)) { index = i;//w w w . j a v a 2 s . c o m } } return index; }
From source file:com.github.akinaru.hcidebugger.activity.HciDebuggerActivity.java
private int getIndex(Spinner spinner, String myString) { int index = 0; for (int i = 0; i < spinner.getCount(); i++) { if (spinner.getItemAtPosition(i).equals(myString)) { index = i;//from w ww. j a v a 2 s. c o m } } return index; }
From source file:com.ezac.gliderlogs.FlightOverviewActivity.java
public void DoSettings() { // get settings.xml view LayoutInflater li = LayoutInflater.from(context); settingsView = li.inflate(R.layout.settings, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context); // set settings.xml to alertdialog builder alertDialogBuilder.setView(settingsView); // get user input for service code final EditText userInput = (EditText) settingsView.findViewById(R.id.editTextDialogUserInput); // set dialog message alertDialogBuilder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override/*from ww w .ja va 2 s.c o m*/ public void onClick(DialogInterface dialog, int id) { SharedPreferences prefs = context.getSharedPreferences("Share", Context.MODE_PRIVATE); prefs.edit().clear(); SharedPreferences.Editor es = prefs.edit(); String[] mTestArray; if (userInput.getText().toString().equals("NoAccess")) { // prefs URL EditText et1 = (EditText) settingsView.findViewById(R.id.setting_url); appURL = et1.getText().toString(); es.putString("com.ezac.gliderlogs.url", appURL).apply(); } // prefs PRE EditText et2 = (EditText) settingsView.findViewById(R.id.setting_pre); appPRE = et2.getText().toString().replace(" ", ""); es.putString("com.ezac.gliderlogs.pre", appPRE).apply(); if (userInput.getText().toString().equals("NoAccess")) { // prefs SCN EditText et3 = (EditText) settingsView.findViewById(R.id.setting_scn); appSCN = et3.getText().toString(); es.putString("com.ezac.gliderlogs.scn", appSCN).apply(); // prefs KEY EditText et4 = (EditText) settingsView.findViewById(R.id.setting_key); appKEY = et4.getText().toString(); es.putString("com.ezac.gliderlogs.key", appKEY).apply(); // prefs KEY EditText et5 = (EditText) settingsView.findViewById(R.id.setting_secret); appSCT = et5.getText().toString(); es.putString("com.ezac.gliderlogs.sct", appSCT).apply(); // prefs Meteo mTestArray = getResources().getStringArray(R.array.meteo_id_arrays); Spinner et6 = (Spinner) settingsView.findViewById(R.id.setting_station); String sel6 = (String) et6.getSelectedItem(); //String sel6_id = ""; for (int i = 0; i < et6.getCount(); i++) { String s1 = (String) et6.getItemAtPosition(i); if (s1.equalsIgnoreCase(sel6)) { appMST = mTestArray[i]; } } es.putString("com.ezac.gliderlogs.mst", appMST).apply(); // prefs Metar EditText et7 = (EditText) settingsView.findViewById(R.id.setting_metar); appMTR = et7.getText().toString(); es.putString("com.ezac.gliderlogs.mst", appMST).apply(); } // prefs Flags CheckBox et9a = (CheckBox) settingsView.findViewById(R.id.setting_menu01); CheckBox et9b = (CheckBox) settingsView.findViewById(R.id.setting_menu02); CheckBox et9c = (CheckBox) settingsView.findViewById(R.id.setting_menu11); CheckBox et9d = (CheckBox) settingsView.findViewById(R.id.setting_menu12); CheckBox et9e = (CheckBox) settingsView.findViewById(R.id.setting_menu13); CheckBox et9f = (CheckBox) settingsView.findViewById(R.id.setting_menu14); CheckBox et9g = (CheckBox) settingsView.findViewById(R.id.setting_menu21); CheckBox et9h = (CheckBox) settingsView.findViewById(R.id.setting_menu22); String et9aa, et9ab; String v[]; if (userInput.getText().toString().equals("To3Myd4T")) { et9aa = et9a.isChecked() ? "true" : "false"; et9ab = et9b.isChecked() ? "true" : "false"; } else { v = appFLG.split(";"); et9aa = v[0]; et9ab = v[1]; } String et9ac = et9c.isChecked() ? "true" : "false"; String et9ad = et9d.isChecked() ? "true" : "false"; String et9ae = et9e.isChecked() ? "true" : "false"; String et9af = et9f.isChecked() ? "true" : "false"; String et9ag = et9g.isChecked() ? "true" : "false"; String et9ah = et9h.isChecked() ? "true" : "false"; appFLG = et9aa + ";" + et9ab + ";" + et9ac + ";" + et9ad + ";" + et9ae + ";" + et9af + ";" + et9ag + ";" + et9ah + ";false;false"; v = appFLG.split(";"); menu.findItem(R.id.action_ezac).setVisible(Boolean.parseBoolean(v[2])); menu.findItem(R.id.action_meteo_group).setVisible(Boolean.parseBoolean(v[3])); menu.findItem(R.id.action_ntm_nld).setVisible(Boolean.parseBoolean(v[4])); menu.findItem(R.id.action_ntm_blx).setVisible(Boolean.parseBoolean(v[4])); menu.findItem(R.id.action_ogn_flarm).setVisible(Boolean.parseBoolean(v[5])); menu.findItem(R.id.action_adsb).setVisible(Boolean.parseBoolean(v[6])); menu.findItem(R.id.action_adsb_lcl).setVisible(Boolean.parseBoolean(v[7])); es.putString("com.ezac.gliderlogs.flg", appFLG).apply(); // adjust value in menu button to value in use MenuItem MenuItem_dur = menu.findItem(R.id.action_45min); MenuItem_dur.setTitle(" " + appPRE + " Min "); if (userInput.getText().toString().equals("To3Myd4T")) { // prefs airfield heading mTestArray = getResources().getStringArray(R.array.heading_arrays); Spinner et10 = (Spinner) settingsView.findViewById(R.id.setting_heading); String sel10 = (String) et10.getSelectedItem(); //String sel10_id = ""; for (int i = 0; i < et10.getCount(); i++) { String s2 = (String) et10.getItemAtPosition(i); if (s2.equalsIgnoreCase(sel10)) { appLND = mTestArray[i]; es.putString("com.ezac.gliderlogs.lnd", appLND).apply(); } } } } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); // create alert dialog & and load it's data AlertDialog alertDialog = alertDialogBuilder.create(); EditText et1 = (EditText) settingsView.findViewById(R.id.setting_url); EditText et2 = (EditText) settingsView.findViewById(R.id.setting_pre); EditText et3 = (EditText) settingsView.findViewById(R.id.setting_scn); EditText et4 = (EditText) settingsView.findViewById(R.id.setting_key); EditText et5 = (EditText) settingsView.findViewById(R.id.setting_secret); Spinner et6 = (Spinner) settingsView.findViewById(R.id.setting_station); EditText et7 = (EditText) settingsView.findViewById(R.id.setting_metar); //EditText et8 = (EditText) settingsView.findViewById(R.id.setting_ntp); CheckBox et9a = (CheckBox) settingsView.findViewById(R.id.setting_menu01); CheckBox et9b = (CheckBox) settingsView.findViewById(R.id.setting_menu02); CheckBox et9c = (CheckBox) settingsView.findViewById(R.id.setting_menu11); CheckBox et9d = (CheckBox) settingsView.findViewById(R.id.setting_menu12); CheckBox et9e = (CheckBox) settingsView.findViewById(R.id.setting_menu13); CheckBox et9f = (CheckBox) settingsView.findViewById(R.id.setting_menu14); CheckBox et9g = (CheckBox) settingsView.findViewById(R.id.setting_menu21); CheckBox et9h = (CheckBox) settingsView.findViewById(R.id.setting_menu22); Spinner et10 = (Spinner) settingsView.findViewById(R.id.setting_heading); et1.setText(appURL); et2.setText(appPRE); et3.setText(appSCN); et4.setText(appKEY); et5.setText(appSCT); // get settings value for meteo station and set spinner String[] mTestArray; mTestArray = getResources().getStringArray(R.array.meteo_id_arrays); for (int i = 0; i < mTestArray.length; i++) { String s = mTestArray[i]; if (s.equals(appMST)) { et6.setSelection(i); } } et7.setText(appMTR); // get settings value for menu tabs and set checkboxes String v[] = appFLG.split(";"); et9a.setChecked(Boolean.parseBoolean(v[0])); et9b.setChecked(Boolean.parseBoolean(v[1])); et9c.setChecked(Boolean.parseBoolean(v[2])); et9d.setChecked(Boolean.parseBoolean(v[3])); et9e.setChecked(Boolean.parseBoolean(v[4])); et9f.setChecked(Boolean.parseBoolean(v[5])); et9g.setChecked(Boolean.parseBoolean(v[6])); et9h.setChecked(Boolean.parseBoolean(v[7])); // re-use mTestArray mTestArray = getResources().getStringArray(R.array.heading_arrays); for (int i = 0; i < mTestArray.length; i++) { String s = mTestArray[i]; if (s.equals(appLND)) { et10.setSelection(i); } } // show it alertDialog.show(); }
From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java
private void setFilelistCurrDir(Spinner tv, String base, String dir) { // tv.setText(dir_text); for (int i = 0; i < tv.getCount(); i++) { String list = (String) tv.getItemAtPosition(i); if (list.equals(base)) { tv.setSelection(i);//from www . j ava 2s.com break; } } ; }
From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java
private void showFileListCache(final ArrayList<FileListCacheItem> fcl, final FileListAdapter fla, final ListView flv, final Spinner spinner) { // ??/* w w w.jav a 2 s . c o m*/ final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.select_file_cache_dlg); // final Button btnOk = // (Button) dialog.findViewById(R.id.select_file_cache_dlg_ok); final Button btnCancel = (Button) dialog.findViewById(R.id.select_file_cache_dlg_cancel); CommonDialog.setDlgBoxSizeCompact(dialog); ((TextView) dialog.findViewById(R.id.select_file_cache_dlg_title)).setText("Select file cache"); ListView lv = (ListView) dialog.findViewById(R.id.select_file_cache_dlg_listview); final ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < fcl.size(); i++) { list.add(fcl.get(i).directory); } Collections.sort(list, new Comparator<String>() { @Override public int compare(String lhs, String rhs) { return lhs.compareToIgnoreCase(rhs); } }); ArrayAdapter<String> adapter = new ArrayAdapter<String>(mContext, R.layout.simple_list_item_1o, list); lv.setAdapter(adapter); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String t_dir = list.get(position); FileListCacheItem dhi = getFileListCache(t_dir, fcl); if (dhi != null) { mIgnoreSpinnerSelection = true; int s_no = -1; for (int i = 0; i < spinner.getCount(); i++) { if (spinner.getItemAtPosition(i).toString().equals(dhi.profile_name)) { s_no = i; break; } } fla.setDataList(dhi.file_list); fla.notifyDataSetChanged(); if (currentTabName.equals(SMBEXPLORER_TAB_LOCAL)) { localBase = dhi.base; if (dhi.base.equals(dhi.directory)) localDir = ""; else localDir = dhi.directory.replace(localBase + "/", ""); replaceDirHist(localDirHist, dhi.directory_history); setFilelistCurrDir(localFileListDirSpinner, localBase, localDir); setFileListPathName(localFileListPathBtn, localFileListCache, localBase, localDir); setEmptyFolderView(); localCurrFLI = dhi; flv.setSelection(0); for (int j = 0; j < localFileListView.getChildCount(); j++) localFileListView.getChildAt(j).setBackgroundColor(Color.TRANSPARENT); localFileListReloadBtn.performClick(); } else if (currentTabName.equals(SMBEXPLORER_TAB_REMOTE)) { remoteBase = dhi.base; if (dhi.base.equals(dhi.directory)) remoteDir = ""; else remoteDir = dhi.directory.replace(remoteBase + "/", ""); replaceDirHist(remoteDirHist, dhi.directory_history); setFilelistCurrDir(remoteFileListDirSpinner, remoteBase, remoteDir); setFileListPathName(remoteFileListPathBtn, remoteFileListCache, remoteBase, remoteDir); setEmptyFolderView(); remoteCurrFLI = dhi; flv.setSelection(0); // Log.v("","base="+remoteBase+", dir="+remoteDir+", histsz="+remoteDirHist.size()); for (int j = 0; j < remoteFileListView.getChildCount(); j++) remoteFileListView.getChildAt(j).setBackgroundColor(Color.TRANSPARENT); if (remoteDir.equals("")) { remoteFileListTopBtn.setEnabled(false); remoteFileListUpBtn.setEnabled(false); } else { remoteFileListTopBtn.setEnabled(true); remoteFileListUpBtn.setEnabled(true); } } if (s_no != -1) spinner.setSelection(s_no); Handler hndl = new Handler(); hndl.postDelayed(new Runnable() { @Override public void run() { mIgnoreSpinnerSelection = false; } }, 100); dialog.dismiss(); } } }); btnCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); }