List of usage examples for android.widget Spinner setAdapter
@Override public void setAdapter(SpinnerAdapter adapter)
From source file:com.sunmeng.educationaladministration.animateview.GoogleCardsActivity.java
/** * Item??//from w w w.j a va2 s.c o m */ public void getDetails() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final Map<String, Object> map; map = (Map<String, Object>) parent.getItemAtPosition(position); LayoutInflater inflater1 = getLayoutInflater(); View view1 = inflater1.inflate(R.layout.activity_extra_detailsinfo, (ViewGroup) findViewById(R.id.toast_layout)); final Spinner spn_extraclassName = (Spinner) view1.findViewById(R.id.spn_uextraclassName); final TextView tv_date = (TextView) view1.findViewById(R.id.ued_date_reply); final EditText et_teacher = (EditText) view1.findViewById(R.id.et_uextrateacher); final EditText et_jointeacher = (EditText) view1.findViewById(R.id.et_uextrajoin); final EditText et_address = (EditText) view1.findViewById(R.id.et_uaddress); final TextView tv_update_reply = (TextView) view1.findViewById(R.id.tvUpdate); final EditText et_uatime = (EditText) view1.findViewById(R.id.et_uatime); img_back = (ImageView) view1.findViewById(R.id.ivBack); img_back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.cancel(); } }); /** * ??? */ httpUtils.send(HttpRequest.HttpMethod.GET, HttpClientUtil.HTTP_URL + "ClassAllServlet", new RequestCallBack() { @Override public void onSuccess(final ResponseInfo responseInfo) { //Toast.makeText(mContext, responseInfo.toString(), Toast.LENGTH_LONG).show(); final List<String> list = new ArrayList<String>(); list.add("cnname"); list.add("cnid"); new AsyncTask<String, String, Map<String, String>>() { @Override protected Map<String, String> doInBackground(String... params) { classNameArr = JsonUtil .getJsonToSpinnerListMap(responseInfo.result.toString(), list); return classNameArr; } @Override protected void onPostExecute(Map<String, String> s) { //android.R.layout.simple_spinner_dropdown_item// //R.layout.myspinner spn_extraclassName.setAdapter( new android.widget.ArrayAdapter<String>(GoogleCardsActivity.this, android.R.layout.simple_spinner_dropdown_item, Utils.getMapListToListString(s))); if (map.get("cnname").toString() != "") { spn_extraclassName.setSelection( Utils.getMapListId(s, map.get("cnname").toString())); spn_extraclassName.setEnabled(false); } else { } // et_classname_reply.setSelection(2, true); } }.execute(""); } @Override public void onFailure(HttpException e, String s) { } }); et_teacher.setText(map.get("ateacher").toString()); et_jointeacher.setText(map.get("ajointeacher").toString()); et_address.setText(map.get("aaddress").toString()); tv_date.setText(map.get("adate").toString()); et_uatime.setText(map.get("atime").toString()); tv_update_reply.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (tv_update_reply.getText().equals("")) { setClickble(true); tv_update_reply.setText("?"); } else if (tv_update_reply.getText().equals("?")) { setClickble(false); tv_update_reply.setText(""); // TODO ?? updateReply(); } } /** * ?? */ private void setClickble(boolean flag) { et_teacher.setEnabled(flag); et_jointeacher.setEnabled(flag); et_address.setEnabled(flag); spn_extraclassName.setEnabled(flag); et_uatime.setEnabled(flag); } public void updateReply() { String etteacher = et_teacher.getText().toString().trim(); String etjointeacher = et_jointeacher.getText().toString().trim(); String ettime = et_uatime.getText().toString().trim(); String etaddress = et_address.getText().toString().trim(); String tvdate = tv_date.getText().toString().trim(); String classnumid = classNameArr .get(spn_extraclassName.getSelectedItem().toString().trim());//?id String id = map.get("aid").toString(); //Toast.makeText(GoogleCardsActivity.this, "="+etteacher+etjointeacher+ettime+etaddress, Toast.LENGTH_SHORT).show(); if ("".equals(etteacher) && "".equals(etjointeacher) && "".equals(etaddress)) { Toast.makeText(GoogleCardsActivity.this, "???", Toast.LENGTH_SHORT) .show(); return; } else { RequestParams params = new RequestParams(); params.addBodyParameter("activitiesupcdate", tvdate); params.addBodyParameter("activitiesuptime", ettime); params.addBodyParameter("activitiesupclassnumid", classnumid); params.addBodyParameter("activitiesupteacher", etteacher); params.addBodyParameter("activitiesupjointeacher", etjointeacher); params.addBodyParameter("activitiesupaddress", etaddress); params.addBodyParameter("activitiesuprid", id); Toast.makeText(GoogleCardsActivity.this, "id==" + id, Toast.LENGTH_SHORT).show(); httpUtils.send(HttpRequest.HttpMethod.POST, HttpClientUtil.HTTP_URL + "ActivitiesUpdateServlet", params, new RequestCallBack() { @Override public void onSuccess(ResponseInfo responseInfo) { Toast.makeText(GoogleCardsActivity.this, "?", Toast.LENGTH_SHORT).show(); getData(); dialog.cancel(); } @Override public void onFailure(HttpException e, String s) { Toast.makeText(GoogleCardsActivity.this, "", Toast.LENGTH_SHORT).show(); } }); } } }); builder = new AlertDialog.Builder(parent.getContext()); builder.setView(view1); dialog = builder.create(); dialog.show(); } }); }
From source file:com.code.android.vibevault.SearchScreen.java
private void launchSettingsDialog() { final SeekBar seek; final Spinner sortSpin; final Spinner searchSpin; final TextView seekValue; // Make the settings dialog. AlertDialog.Builder ad = new AlertDialog.Builder(this); ad.setTitle("Search Settings"); View v = LayoutInflater.from(this).inflate(R.layout.scrollable_settings_dialog, null); ad.setPositiveButton("Okay.", new android.content.DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int arg1) { }/*from w ww .j a va 2 s . c om*/ }); // Grab all the GUI widgets. seek = (SeekBar) v.findViewById(R.id.NumResultsSeekBar); seek.setProgress(Integer.valueOf(VibeVault.db.getPref("numResults")) - 10); sortSpin = (Spinner) v.findViewById(R.id.SortSpinner); searchSpin = (Spinner) v.findViewById(R.id.SearchSpinner); seekValue = (TextView) v.findViewById(R.id.SeekBarValue); seekValue.setText(VibeVault.db.getPref("numResults")); // Set the seek bar to its current value, and set up a Listener. seek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { seekValue.setText(String.valueOf(progress + 10)); VibeVault.db.updatePref("numResults", String.valueOf(progress + 10)); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); // Set up the spinner, and set up it's OnItemSelectedListener. ArrayAdapter<String> sortAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, VibeVault.sortChoices); sortAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sortSpin.setAdapter(sortAdapter); int sortPos = 1; String sortOrder = VibeVault.db.getPref("sortOrder"); for (int i = 0; i < VibeVault.sortChoices.length; i++) { if (VibeVault.sortChoices[i].equals(sortOrder)) sortPos = i; } sortSpin.setSelection(sortPos); sortSpin.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View view, int arg2, long arg3) { int selected = arg0.getSelectedItemPosition(); VibeVault.db.updatePref("sortOrder", VibeVault.sortChoices[selected]); } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); ArrayAdapter<String> searchAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, VibeVault.searchChoices); searchAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); searchSpin.setAdapter(searchAdapter); int searchPos = 1; String searchOrder = VibeVault.searchPref; for (int i = 0; i < VibeVault.searchChoices.length; i++) { if (VibeVault.searchChoices[i].equals(searchOrder)) searchPos = i; } searchSpin.setSelection(searchPos); searchSpin.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View view, int arg2, long arg3) { int selected = arg0.getSelectedItemPosition(); VibeVault.searchPref = VibeVault.searchChoices[selected]; if (VibeVault.searchPref.equals("Artist") && artistSearchInput.getText().equals("")) { artistSearchInput.setHint("Search Artists..."); } else if (VibeVault.searchPref.equals("Show/Artist Description") && artistSearchInput.getText().equals("")) { artistSearchInput.setHint("Search Descriptions..."); } } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); // Show the settings screen. ad.setView(v); ad.show(); }
From source file:com.fitme.MainActivity.java
public void onExerciseCreationRequested(final String trainName, final TrainingsListAdapter tla) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.title_add_exercise_dialog); View view = getLayoutInflater().inflate(R.layout.dialog_add_exercise, null); builder.setView(view);// www. j av a 2 s . co m builder.setPositiveButton(android.R.string.ok, null); builder.setNegativeButton(android.R.string.cancel, null); final AlertDialog dialogEx = builder.create(); dialogEx.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { Button positive = dialogEx.getButton(AlertDialog.BUTTON_POSITIVE); positive.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Spinner spinMuscleGroup = (Spinner) dialogEx.findViewById(R.id.spinner_select_mg_ex); Spinner spinExName = (Spinner) dialogEx.findViewById(R.id.spinner_select_ex); NumberPicker numpickRepeats = (NumberPicker) dialogEx .findViewById(R.id.numberpicker_repeats_ex); //Since we decide to have all spinners pre-populated no need to check data Exercise e = new Exercise(); e.setName(spinExName.getSelectedItem().toString()); e.setMuscleGroup(spinMuscleGroup.getSelectedItem().toString()); e.setRepeats(numpickRepeats.getValue()); //Identifying program and training long programId = MainActivity.this.getActiveProgramId(); TrainingDAO td = new TrainingDAO(MainActivity.this); long trId = td.getTrainingByName(programId, trainName).getId(); e.setTrainId(trId); //Insert new entry to db ExerciseDAO ed = new ExerciseDAO(MainActivity.this); long exId = ed.createExercise(e).getId(); e.setId(exId); Toast.makeText(MainActivity.this, getText(R.string.toast_add_exercise_ok), Toast.LENGTH_SHORT).show(); tla.addExercise(e, trainName); dialogEx.dismiss(); } }); } }); dialogEx.show(); // Populate dialog fields NumberPicker np = (NumberPicker) dialogEx.findViewById(R.id.numberpicker_repeats_ex); final Spinner spinMuscleGroup = (Spinner) dialogEx.findViewById(R.id.spinner_select_mg_ex); final Spinner spinExName = (Spinner) dialogEx.findViewById(R.id.spinner_select_ex); np.setMaxValue(Exercise.MAX_REPEATS); np.setMinValue(Exercise.MIN_REPEATS); //Filling muscle groups spinner String[] muscleGroups = getResources().getStringArray(R.array.muscle_groups); ArrayAdapter<String> mgAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, muscleGroups); spinMuscleGroup.setAdapter(mgAdapter); spinMuscleGroup.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { String arrayName = ("exercises_" + spinMuscleGroup.getSelectedItem().toString()).toLowerCase(); int id = getResources().getIdentifier(arrayName, "array", MainActivity.this.getPackageName()); String[] exercises = getResources().getStringArray(id); ArrayAdapter<String> exAdapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_spinner_item, exercises); spinExName.setAdapter(exAdapter); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); spinMuscleGroup.setSelection(1); }
From source file:cl.gisred.android.PowerOnActivity.java
public void dialogBusqueda() { AlertDialog.Builder dialogBusqueda = new AlertDialog.Builder(this); dialogBusqueda.setTitle("Busqueda"); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.dialog_busqueda, null); dialogBusqueda.setView(v);/*from www . j a v a 2 s .co m*/ Spinner spinner = (Spinner) v.findViewById(R.id.spinnerBusqueda); final LinearLayout llBuscar = (LinearLayout) v.findViewById(R.id.llBuscar); final LinearLayout llDireccion = (LinearLayout) v.findViewById(R.id.llBuscarDir); final LinearLayout llOrden = (LinearLayout) v.findViewById(R.id.llBuscarOrden); ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, searchArray); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { SpiBusqueda = position; if (position == 6) { if (llDireccion != null) llDireccion.setVisibility(View.GONE); if (llBuscar != null) llBuscar.setVisibility(View.GONE); if (llOrden != null) llOrden.setVisibility(View.VISIBLE); } else if (position == 4) { if (llBuscar != null) llBuscar.setVisibility(View.GONE); if (llOrden != null) llOrden.setVisibility(View.GONE); if (llDireccion != null) llDireccion.setVisibility(View.VISIBLE); } else { if (llDireccion != null) llDireccion.setVisibility(View.GONE); if (llOrden != null) llOrden.setVisibility(View.GONE); if (llBuscar != null) llBuscar.setVisibility(View.VISIBLE); } } @Override public void onNothingSelected(AdapterView<?> parent) { Toast.makeText(getApplicationContext(), "Nada seleccionado", Toast.LENGTH_SHORT).show(); } }); final EditText eSearch = (EditText) v.findViewById(R.id.txtBuscar); final EditText eStreet = (EditText) v.findViewById(R.id.txtCalle); final EditText eNumber = (EditText) v.findViewById(R.id.txtNum); final EditText eOrder = (EditText) v.findViewById(R.id.txtOrden); dialogBusqueda.setPositiveButton("Buscar", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (SpiBusqueda == 4) { txtBusqueda = new String(); if (!eStreet.getText().toString().isEmpty()) txtBusqueda = (eNumber.getText().toString().trim().isEmpty()) ? "0 " : eNumber.getText().toString().trim() + " "; txtBusqueda = txtBusqueda + eStreet.getText().toString(); } else if (SpiBusqueda == 6) { txtBusqueda = eOrder.getText().toString() + "-1"; } else { txtBusqueda = eSearch.getText().toString(); } if (txtBusqueda.trim().isEmpty()) { Toast.makeText(myMapView.getContext(), "Debe ingresar un valor", Toast.LENGTH_SHORT).show(); } else { // Escala de calle para busquedas por default iBusqScale = 4000; switch (SpiBusqueda) { case 0: callQuery(txtBusqueda, getValueByEmp("CLIENTES_XY_006.nis"), LyCLIENTES.getUrl().concat("/0")); if (LyCLIENTES.getLayers() != null && LyCLIENTES.getLayers().length > 0) iBusqScale = LyCLIENTES.getLayers()[0].getLayerServiceInfo().getMinScale(); break; case 1: callQuery(txtBusqueda, "codigo", LySED.getUrl().concat("/1")); if (LySED.getLayers() != null && LySED.getLayers().length > 1) iBusqScale = LySED.getLayers()[1].getLayerServiceInfo().getMinScale(); break; case 2: callQuery(txtBusqueda, "rotulo", LyPOSTES.getUrl().concat("/0")); if (LyPOSTES.getLayers() != null && LyPOSTES.getLayers().length > 0) iBusqScale = LyPOSTES.getLayers()[0].getLayerServiceInfo().getMinScale(); break; case 3: callQuery(txtBusqueda, "serie_medidor", LyMEDIDORES.getUrl().concat("/1")); if (LyMEDIDORES.getLayers() != null && LyMEDIDORES.getLayers().length > 1) iBusqScale = LyMEDIDORES.getLayers()[1].getLayerServiceInfo().getMinScale(); break; case 4: iBusqScale = 5000; String[] sBuscar = { eStreet.getText().toString(), eNumber.getText().toString() }; String[] sFields = { "nombre_calle", "numero" }; callQuery(sBuscar, sFields, LyDIRECCIONES.getUrl().concat("/0")); break; case 5: callQuery(txtBusqueda, new String[] { "id_equipo", "nombre" }, LyEQUIPOSLINEA.getUrl().concat("/0")); if (LyEQUIPOSLINEA.getLayers() != null && LyEQUIPOSLINEA.getLayers().length > 0) iBusqScale = LyEQUIPOSLINEA.getLayers()[0].getLayerServiceInfo().getMinScale(); break; case 6: callQuery(txtBusqueda, getValueByEmp("ARCGIS.dbo.POWERON_CLIENTES.id_orden"), LyPOCLIENTES.getUrl().concat("/1")); if (LyPOCLIENTES.getLayers() != null && LyPOCLIENTES.getLayers().length > 0) if (LyPOCLIENTES.getLayers()[1].getLayerServiceInfo().getMinScale() > 0) iBusqScale = LyPOCLIENTES.getLayers()[1].getLayerServiceInfo().getMinScale(); break; case 7: callQueryInt(txtBusqueda, getValueByEmp("ARCGIS.dbo.POWERON_CLIENTES.id_incidencia"), LyPOCLIENTES.getUrl().concat("/1")); if (LyPOCLIENTES.getLayers() != null && LyPOCLIENTES.getLayers().length > 0) if (LyPOCLIENTES.getLayers()[1].getLayerServiceInfo().getMinScale() > 0) iBusqScale = LyPOCLIENTES.getLayers()[1].getLayerServiceInfo().getMinScale(); break; } } } }); dialogBusqueda.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); dialogBusqueda.show(); }
From source file:com.initialxy.cordova.themeablebrowser.ThemeableBrowser.java
/** * Display a new browser with the specified URL. * * @param url// w ww.j a va 2 s . c o m * @param features * @return */ public String showWebPage(final String url, final Options features) { final CordovaWebView thatWebView = this.webView; // Create dialog in new thread Runnable runnable = new Runnable() { @SuppressLint("NewApi") public void run() { // Let's create the main dialog dialog = new ThemeableBrowserDialog(cordova.getActivity(), android.R.style.Theme_Black_NoTitleBar, features.hardwareback); if (!features.disableAnimation) { dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog; } dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); dialog.setThemeableBrowser(getThemeableBrowser()); // Main container layout ViewGroup main = null; if (features.fullscreen) { main = new FrameLayout(cordova.getActivity()); } else { main = new LinearLayout(cordova.getActivity()); ((LinearLayout) main).setOrientation(LinearLayout.VERTICAL); } // Toolbar layout Toolbar toolbarDef = features.toolbar; FrameLayout toolbar = new FrameLayout(cordova.getActivity()); toolbar.setBackgroundColor(hexStringToColor( toolbarDef != null && toolbarDef.color != null ? toolbarDef.color : "#ffffffff")); toolbar.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, dpToPixels(toolbarDef != null ? toolbarDef.height : TOOLBAR_DEF_HEIGHT))); if (toolbarDef != null && (toolbarDef.image != null || toolbarDef.wwwImage != null)) { try { Drawable background = getImage(toolbarDef.image, toolbarDef.wwwImage, toolbarDef.wwwImageDensity); setBackground(toolbar, background); } catch (Resources.NotFoundException e) { emitError(ERR_LOADFAIL, String.format("Image for toolbar, %s, failed to load", toolbarDef.image)); } catch (IOException ioe) { emitError(ERR_LOADFAIL, String.format("Image for toolbar, %s, failed to load", toolbarDef.wwwImage)); } } // Left Button Container layout LinearLayout leftButtonContainer = new LinearLayout(cordova.getActivity()); FrameLayout.LayoutParams leftButtonContainerParams = new FrameLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); leftButtonContainerParams.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL; leftButtonContainer.setLayoutParams(leftButtonContainerParams); leftButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL); // Right Button Container layout LinearLayout rightButtonContainer = new LinearLayout(cordova.getActivity()); FrameLayout.LayoutParams rightButtonContainerParams = new FrameLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); rightButtonContainerParams.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL; rightButtonContainer.setLayoutParams(rightButtonContainerParams); rightButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL); // Edit Text Box edittext = new EditText(cordova.getActivity()); RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1); textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5); edittext.setLayoutParams(textLayoutParams); edittext.setSingleLine(true); edittext.setText(url); edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI); edittext.setImeOptions(EditorInfo.IME_ACTION_GO); edittext.setInputType(InputType.TYPE_NULL); // Will not except input... Makes the text NON-EDITABLE edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(edittext.getText().toString()); return true; } return false; } }); // Back button final Button back = createButton(features.backButton, "back button", new View.OnClickListener() { public void onClick(View v) { emitButtonEvent(features.backButton, inAppWebView.getUrl()); if (features.backButtonCanClose && !canGoBack()) { closeDialog(); } else { goBack(); } } }); if (back != null) { back.setEnabled(features.backButtonCanClose); } // Forward button final Button forward = createButton(features.forwardButton, "forward button", new View.OnClickListener() { public void onClick(View v) { emitButtonEvent(features.forwardButton, inAppWebView.getUrl()); goForward(); } }); if (forward != null) { forward.setEnabled(false); } // Close/Done button Button close = createButton(features.closeButton, "close button", new View.OnClickListener() { public void onClick(View v) { emitButtonEvent(features.closeButton, inAppWebView.getUrl()); closeDialog(); } }); // Menu button Spinner menu = features.menu != null ? new MenuSpinner(cordova.getActivity()) : null; if (menu != null) { menu.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); menu.setContentDescription("menu button"); setButtonImages(menu, features.menu, DISABLED_ALPHA); // We are not allowed to use onClickListener for Spinner, so we will use // onTouchListener as a fallback. menu.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { emitButtonEvent(features.menu, inAppWebView.getUrl()); } return false; } }); if (features.menu.items != null) { HideSelectedAdapter<EventLabel> adapter = new HideSelectedAdapter<EventLabel>( cordova.getActivity(), android.R.layout.simple_spinner_item, features.menu.items); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); menu.setAdapter(adapter); menu.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { if (inAppWebView != null && i < features.menu.items.length) { emitButtonEvent(features.menu.items[i], inAppWebView.getUrl(), i); } } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); } } // Title final TextView title = features.title != null ? new TextView(cordova.getActivity()) : null; final TextView subtitle = features.title != null ? new TextView(cordova.getActivity()) : null; if (title != null) { FrameLayout.LayoutParams titleParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.FILL_PARENT); titleParams.gravity = Gravity.CENTER; title.setLayoutParams(titleParams); title.setSingleLine(); title.setEllipsize(TextUtils.TruncateAt.END); title.setGravity(Gravity.CENTER | Gravity.TOP); title.setTextColor( hexStringToColor(features.title.color != null ? features.title.color : "#000000ff")); title.setTypeface(title.getTypeface(), Typeface.BOLD); title.setTextSize(TypedValue.COMPLEX_UNIT_PT, 8); FrameLayout.LayoutParams subtitleParams = new FrameLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.FILL_PARENT); titleParams.gravity = Gravity.CENTER; subtitle.setLayoutParams(subtitleParams); subtitle.setSingleLine(); subtitle.setEllipsize(TextUtils.TruncateAt.END); subtitle.setGravity(Gravity.CENTER | Gravity.BOTTOM); subtitle.setTextColor(hexStringToColor( features.title.subColor != null ? features.title.subColor : "#000000ff")); subtitle.setTextSize(TypedValue.COMPLEX_UNIT_PT, 6); subtitle.setVisibility(View.GONE); if (features.title.staticText != null) { title.setGravity(Gravity.CENTER); title.setText(features.title.staticText); } else { subtitle.setVisibility(View.VISIBLE); } } // WebView inAppWebView = new WebView(cordova.getActivity()); final ViewGroup.LayoutParams inAppWebViewParams = features.fullscreen ? new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT) : new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0); if (!features.fullscreen) { ((LinearLayout.LayoutParams) inAppWebViewParams).weight = 1; } inAppWebView.setLayoutParams(inAppWebViewParams); inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView)); WebViewClient client = new ThemeableBrowserClient(thatWebView, new PageLoadListener() { @Override public void onPageStarted(String url) { if (inAppWebView != null && title != null && features.title != null && features.title.staticText == null && features.title.showPageTitle && features.title.loadingText != null) { title.setText(features.title.loadingText); subtitle.setText(url); } } @Override public void onPageFinished(String url, boolean canGoBack, boolean canGoForward) { if (inAppWebView != null && title != null && features.title != null && features.title.staticText == null && features.title.showPageTitle) { title.setText(inAppWebView.getTitle()); subtitle.setText(inAppWebView.getUrl()); } if (back != null) { back.setEnabled(canGoBack || features.backButtonCanClose); } if (forward != null) { forward.setEnabled(canGoForward); } } }); inAppWebView.setWebViewClient(client); WebSettings settings = inAppWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setBuiltInZoomControls(features.zoom); settings.setDisplayZoomControls(false); settings.setPluginState(android.webkit.WebSettings.PluginState.ON); //Toggle whether this is enabled or not! Bundle appSettings = cordova.getActivity().getIntent().getExtras(); boolean enableDatabase = appSettings == null || appSettings.getBoolean("ThemeableBrowserStorageEnabled", true); if (enableDatabase) { String databasePath = cordova.getActivity().getApplicationContext() .getDir("themeableBrowserDB", Context.MODE_PRIVATE).getPath(); settings.setDatabasePath(databasePath); settings.setDatabaseEnabled(true); } settings.setDomStorageEnabled(true); if (features.clearcache) { CookieManager.getInstance().removeAllCookie(); } else if (features.clearsessioncache) { CookieManager.getInstance().removeSessionCookie(); } inAppWebView.loadUrl(url); inAppWebView.getSettings().setLoadWithOverviewMode(true); inAppWebView.getSettings().setUseWideViewPort(true); inAppWebView.requestFocus(); inAppWebView.requestFocusFromTouch(); // Add buttons to either leftButtonsContainer or // rightButtonsContainer according to user's alignment // configuration. int leftContainerWidth = 0; int rightContainerWidth = 0; if (features.customButtons != null) { for (int i = 0; i < features.customButtons.length; i++) { final BrowserButton buttonProps = features.customButtons[i]; final int index = i; Button button = createButton(buttonProps, String.format("custom button at %d", i), new View.OnClickListener() { @Override public void onClick(View view) { if (inAppWebView != null) { emitButtonEvent(buttonProps, inAppWebView.getUrl(), index); } } }); if (ALIGN_RIGHT.equals(buttonProps.align)) { rightButtonContainer.addView(button); rightContainerWidth += button.getLayoutParams().width; } else { leftButtonContainer.addView(button, 0); leftContainerWidth += button.getLayoutParams().width; } } } // Back and forward buttons must be added with special ordering logic such // that back button is always on the left of forward button if both buttons // are on the same side. if (forward != null && features.forwardButton != null && !ALIGN_RIGHT.equals(features.forwardButton.align)) { leftButtonContainer.addView(forward, 0); leftContainerWidth += forward.getLayoutParams().width; } if (back != null && features.backButton != null && ALIGN_RIGHT.equals(features.backButton.align)) { rightButtonContainer.addView(back); rightContainerWidth += back.getLayoutParams().width; } if (back != null && features.backButton != null && !ALIGN_RIGHT.equals(features.backButton.align)) { leftButtonContainer.addView(back, 0); leftContainerWidth += back.getLayoutParams().width; } if (forward != null && features.forwardButton != null && ALIGN_RIGHT.equals(features.forwardButton.align)) { rightButtonContainer.addView(forward); rightContainerWidth += forward.getLayoutParams().width; } if (menu != null) { if (features.menu != null && ALIGN_RIGHT.equals(features.menu.align)) { rightButtonContainer.addView(menu); rightContainerWidth += menu.getLayoutParams().width; } else { leftButtonContainer.addView(menu, 0); leftContainerWidth += menu.getLayoutParams().width; } } if (close != null) { if (features.closeButton != null && ALIGN_RIGHT.equals(features.closeButton.align)) { rightButtonContainer.addView(close); rightContainerWidth += close.getLayoutParams().width; } else { leftButtonContainer.addView(close, 0); leftContainerWidth += close.getLayoutParams().width; } } // Add the views to our toolbar toolbar.addView(leftButtonContainer); // Don't show address bar. // toolbar.addView(edittext); toolbar.addView(rightButtonContainer); if (title != null) { int titleMargin = Math.max(leftContainerWidth, rightContainerWidth); FrameLayout.LayoutParams titleParams = (FrameLayout.LayoutParams) title.getLayoutParams(); titleParams.setMargins(titleMargin, 8, titleMargin, 0); toolbar.addView(title); } if (subtitle != null) { int subtitleMargin = Math.max(leftContainerWidth, rightContainerWidth); FrameLayout.LayoutParams subtitleParams = (FrameLayout.LayoutParams) subtitle.getLayoutParams(); subtitleParams.setMargins(subtitleMargin, 0, subtitleMargin, 8); toolbar.addView(subtitle); } if (features.fullscreen) { // If full screen mode, we have to add inAppWebView before adding toolbar. main.addView(inAppWebView); } // Don't add the toolbar if its been disabled if (features.location) { // Add our toolbar to our main view/layout main.addView(toolbar); } if (!features.fullscreen) { // If not full screen, we add inAppWebView after adding toolbar. main.addView(inAppWebView); } WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.MATCH_PARENT; dialog.setContentView(main); dialog.show(); dialog.getWindow().setAttributes(lp); // the goal of openhidden is to load the url and not display it // Show() needs to be called to cause the URL to be loaded if (features.hidden) { dialog.hide(); } } }; this.cordova.getActivity().runOnUiThread(runnable); return ""; }
From source file:cl.gisred.android.CatastroActivity.java
private void setSpinnerDialog(int idLayout, View v) { ArrayAdapter<CharSequence> adapter; switch (idLayout) { case R.layout.dialog_poste: Spinner spTipoPoste = (Spinner) v.findViewById(R.id.spinnerTipoPoste); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayTipoPoste);/* w ww .java 2 s. c om*/ spTipoPoste.setAdapter(adapter); Spinner spTipoTension = (Spinner) v.findViewById(R.id.spinnerTension); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayTension); spTipoTension.setAdapter(adapter); break; case R.layout.dialog_direccion: //Setear Spinner y recuperar valores Spinner spTipoEdif = (Spinner) v.findViewById(R.id.spinnerTipoEdif); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayTipoEdif); spTipoEdif.setAdapter(adapter); break; case R.layout.dialog_cliente: Spinner spTipoMedidor = (Spinner) v.findViewById(R.id.spinnerTipoMedidor); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayMedidor); spTipoMedidor.setAdapter(adapter); Spinner spTecMedidor = (Spinner) v.findViewById(R.id.spinnerTecMedidor); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayTecMedidor); spTecMedidor.setAdapter(adapter); Spinner spEmpalme = (Spinner) v.findViewById(R.id.spinnerTipoEmpalme); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayEmpalme); spEmpalme.setAdapter(adapter); Spinner spTipoFase = (Spinner) v.findViewById(R.id.spinnerFaseConex); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayTipoFase); spTipoFase.setAdapter(adapter); break; case R.layout.dialog_cliente_cnr: Spinner spTipoMedidorCnr = (Spinner) v.findViewById(R.id.spinnerTipoMedidor); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayMedidor); spTipoMedidorCnr.setAdapter(adapter); Spinner spTecMedidorCnr = (Spinner) v.findViewById(R.id.spinnerTecMedidor); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayTecMedidor); spTecMedidorCnr.setAdapter(adapter); Spinner spEmpalmeCnr = (Spinner) v.findViewById(R.id.spinnerTipoEmpalme); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayEmpalme); spEmpalmeCnr.setAdapter(adapter); Spinner spTipoCnr = (Spinner) v.findViewById(R.id.spinnerTipoCNR); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayTipoCnr); spTipoCnr.setAdapter(adapter); Spinner spTipoFaseCnr = (Spinner) v.findViewById(R.id.spinnerFaseConex); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayTipoFase); spTipoFaseCnr.setAdapter(adapter); break; } }
From source file:cl.gisred.android.CatastroActivity.java
public void setActionsForm(final int idRes, String sNombre) { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(idRes, null); final int topeWidth = 650; ArrayAdapter<CharSequence> adapter; DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); int widthSize = displayMetrics.widthPixels; int widthScale = (widthSize * 3) / 4; if (topeWidth < widthScale) widthScale = topeWidth;/*from w w w . j av a2s .c o m*/ v.setMinimumWidth(widthScale); formCrear.setTitle(sNombre); formCrear.setContentView(v); idResLayoutSelect = idRes; Spinner spTipoEquipo = (Spinner) v.findViewById(R.id.spinnerTipoEquipo); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayTipoEquipo); spTipoEquipo.setAdapter(adapter); Spinner spTipoCaja = (Spinner) v.findViewById(R.id.spinnerTipoCaja); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayTipoCaja); spTipoCaja.setAdapter(adapter); Spinner spTipoConex = (Spinner) v.findViewById(R.id.spinnerTipoConex); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayTipoConex); spTipoConex.setAdapter(adapter); Spinner spEstadoMedidor = (Spinner) v.findViewById(R.id.spinnerEstadoMedidor); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayEstadoMedidor); spEstadoMedidor.setAdapter(adapter); Spinner spPropiedad = (Spinner) v.findViewById(R.id.spinnerPropiedad); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayPropiedad); spPropiedad.setAdapter(adapter); Spinner spAccesoLectura = (Spinner) v.findViewById(R.id.spinnerAccesoLectura); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayAccesoLectura); spAccesoLectura.setAdapter(adapter); Spinner spTipoIrregular = (Spinner) v.findViewById(R.id.spinnerTipoIrregular); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayTipoIrregularidad); spTipoIrregular.setAdapter(adapter); Spinner spResultado = (Spinner) v.findViewById(R.id.spinnerResultado); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayResultadoCatastro); spResultado.setAdapter(adapter); ImageButton btnIdentPoste = (ImageButton) v.findViewById(R.id.btnPoste); btnIdentPoste.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { formCrear.hide(); bMapTap = true; bCallOut = true; oLySelectAsoc = LyAddPoste; oLyExistAsoc = LyPOSTES; oLyExistAsoc.setVisible(true); myMapView.zoomToScale(ldm.getPoint(), oLyExistAsoc.getMinScale() * 0.9); Log.w("[CatastroActivity]", "HIDE FORM POSTE and Zoom"); setValueToAsoc(getLayoutContenedor(view)); } }); btnUbicacion = (ImageButton) v.findViewById(R.id.btnUbicacion); btnUbicacion.setColorFilter(Color.RED); btnUbicacion.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { bMapTap = true; formCrear.hide(); } }); ImageButton btnClose = (ImageButton) v.findViewById(R.id.btnCancelar); btnClose.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { cerrarFormCrear(false, v); } }); ImageButton btnOk = (ImageButton) v.findViewById(R.id.btnConfirmar); btnOk.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { cerrarFormCrear(true, v); } }); arrayTouchs = new ArrayList<>(); setEnabledDialog(false); formCrear.show(); dialogCur = formCrear; }
From source file:com.juick.android.MessageMenu.java
protected void runActions() { if (!isDialogMode()) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); final CharSequence[] items = new CharSequence[menuActions.size()]; for (int j = 0; j < items.length; j++) { items[j] = menuActions.get(j).title; }// www.java2 s . com builder.setItems(items, this); final AlertDialog alertDialog = builder.create(); alertDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { ColorsTheme.ColorTheme colorTheme = JuickMessagesAdapter.getColorTheme(activity); ColorDrawable divider = new ColorDrawable( colorTheme.getColor(ColorsTheme.ColorKey.COMMON_BACKGROUND, 0xFFFFFFFF)); alertDialog.getListView().setDivider(divider); alertDialog.getListView().setDividerHeight(1); } }); alertDialog.show(); final ListAdapter adapter = alertDialog.getListView().getAdapter(); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(activity); float menuFontScale = 1; try { menuFontScale = Float.parseFloat(sp.getString("menuFontScale", "1.0")); } catch (Exception e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } final boolean compressedMenu = sp.getBoolean("compressedMenu", false); final boolean singleLineMenu = sp.getBoolean("singleLineMenu", false); final float finalMenuFontScale = menuFontScale; final int screenHeight = activity.getWindow().getWindowManager().getDefaultDisplay().getHeight(); alertDialog.getListView().setAdapter(new ListAdapter() { @Override public boolean areAllItemsEnabled() { return adapter.areAllItemsEnabled(); } @Override public boolean isEnabled(int position) { return adapter.isEnabled(position); } @Override public void registerDataSetObserver(DataSetObserver observer) { adapter.registerDataSetObserver(observer); } @Override public void unregisterDataSetObserver(DataSetObserver observer) { adapter.unregisterDataSetObserver(observer); } @Override public int getCount() { return items.length; } @Override public Object getItem(int position) { return adapter.getItem(position); } @Override public long getItemId(int position) { return adapter.getItemId(position); } @Override public boolean hasStableIds() { return adapter.hasStableIds(); } @Override public View getView(int position, View convertView, ViewGroup parent) { View retval = adapter.getView(position, null, parent); if (retval instanceof TextView) { TextView tv = (TextView) retval; if (compressedMenu) { int minHeight = (int) ((screenHeight * 0.7) / getCount()); tv.setMinHeight(minHeight); tv.setMinimumHeight(minHeight); } if (singleLineMenu) { tv.setSingleLine(true); tv.setEllipsize(TextUtils.TruncateAt.MIDDLE); } tv.setTextSize(22 * finalMenuFontScale); } return retval; } @Override public int getItemViewType(int position) { return adapter.getItemViewType(position); } @Override public int getViewTypeCount() { return adapter.getViewTypeCount(); } @Override public boolean isEmpty() { return adapter.isEmpty(); } }); } else { AlertDialog.Builder builder = new AlertDialog.Builder( new ContextThemeWrapper(activity, R.style.Theme_Sherlock)); View dialogView = activity.getLayoutInflater().inflate(R.layout.message_menu2, null); builder.setView(dialogView); builder.setCancelable(true); int width = activity.getWindowManager().getDefaultDisplay().getWidth(); View scrollView = dialogView.findViewById(R.id.scrollView); scrollView.getLayoutParams().width = (int) (width * 0.90); final AlertDialog alertDialog = builder.create(); alertDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { //MainActivity.restyleChildrenOrWidget(alertDialog.getWindow().getDecorView()); } }); TextView messageNo = (TextView) dialogView.findViewById(R.id.message_no); messageNo.setText(listSelectedItem.getDisplayMessageNo()); Spinner openUrl = (Spinner) dialogView.findViewById(R.id.open_url); Button singleURL = (Button) dialogView.findViewById(R.id.single_url); if (urls != null && urls.size() == 1) { singleURL.setVisibility(View.VISIBLE); openUrl.setVisibility(View.GONE); SpannableStringBuilder sb = new SpannableStringBuilder(); sb.append(urls.get(0)); sb.setSpan(new UnderlineSpan(), 0, sb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); singleURL.setText(sb); singleURL.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); launchURL(listSelectedItem.getMID(), urls.get(0)); } }); } else if (urls != null && urls.size() > 0) { singleURL.setVisibility(View.GONE); openUrl.setVisibility(View.VISIBLE); openUrl.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position != 0) { alertDialog.dismiss(); launchURL(listSelectedItem.getMID(), urls.get(position)); } } @Override public void onNothingSelected(AdapterView<?> parent) { //To change body of implemented methods use File | Settings | File Templates. } }); urls.add(0, activity.getString(R.string.ClickToSelectURL)); openUrl.setAdapter(new BaseAdapter() { @Override public int getCount() { return urls.size(); } @Override public Object getItem(int position) { return position; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { View rowView = activity.getLayoutInflater().inflate(android.R.layout.simple_list_item_1, null); TextView textView = (TextView) rowView.findViewById(android.R.id.text1); textView.setSingleLine(false); textView.setMaxLines(5); SpannableStringBuilder sb = new SpannableStringBuilder(); sb.append(urls.get(position)); if (position == 0) { textView.setTextColor(0xFF808080); } else { sb.setSpan(new UnderlineSpan(), 0, sb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } textView.setText(sb); return rowView; } }); } else { openUrl.setVisibility(View.GONE); singleURL.setVisibility(View.GONE); } final String UName = listSelectedItem.User.UName; View recommendMessage = dialogView.findViewById(R.id.recommend_message); View deleteMessage = dialogView.findViewById(R.id.delete_message); View saveMessage = dialogView.findViewById(R.id.save_message); View unsaveMessage = dialogView.findViewById(R.id.unsave_message); //View subscribeUser = dialogView.findViewById(R.id.subscribe_user); View subscribeMessage = dialogView.findViewById(R.id.subscribe_message); //View unsubscribeUser = dialogView.findViewById(R.id.unsubscribe_user); View unsubscribeMessage = dialogView.findViewById(R.id.unsubscribe_message); View translateMessage = dialogView.findViewById(R.id.translate_message); View shareMessage = dialogView.findViewById(R.id.share_message); //View blacklistUser = dialogView.findViewById(R.id.blacklist_user); //View filterUser = dialogView.findViewById(R.id.filter_user); //View userBlog = dialogView.findViewById(R.id.user_blog); //View userStats = dialogView.findViewById(R.id.user_stats); View openMessageInBrowser = dialogView.findViewById(R.id.open_message_in_browser); Button userCenter = (Button) dialogView.findViewById(R.id.user_center); if (null == dialogView.findViewById(R.id.column_3)) { // only for portrait userCenter.setText("@" + listSelectedItem.User.UName + " " + userCenter.getText()); } unsubscribeMessage.setEnabled(listSelectedItem.getRID() == 0); subscribeMessage.setEnabled(listSelectedItem.getRID() == 0); unsaveMessage.setEnabled(listSelectedItem.getRID() == 0); recommendMessage.setEnabled(listSelectedItem.getRID() == 0); if (UName.equalsIgnoreCase(JuickAPIAuthorizer.getJuickAccountName(activity.getApplicationContext()))) { recommendMessage.setVisibility(View.GONE); } else { deleteMessage.setVisibility(View.GONE); } if (messagesSource instanceof SavedMessagesSource) { saveMessage.setVisibility(View.GONE); } else { unsaveMessage.setVisibility(View.GONE); } recommendMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); actionRecommendMessage(); } }); deleteMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); actionDeleteMessage(); } }); saveMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); actionSaveMessage(); } }); unsaveMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); actionUnsaveMessage(); } }); // subscribeUser.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // alertDialog.dismiss(); // actionSubscribeUser(); // } // }); subscribeMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); actionSubscribeMessage(); } }); // unsubscribeUser.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // alertDialog.dismiss(); // actionUnsubscribeUser(); // } // }); unsubscribeMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); actionUnsubscribeMessage(); } }); translateMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); actionTranslateMessage(); } }); shareMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); actionShareMessage(); } }); // blacklistUser.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // alertDialog.dismiss(); // actionBlacklistUser(); // } // }); // filterUser.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // alertDialog.dismiss(); // actionFilterUser(UName); // } // }); // userBlog.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // alertDialog.dismiss(); // actionUserBlog(); // } // }); // userStats.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // alertDialog.dismiss(); // actionUserStats(); // } // }); openMessageInBrowser.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); actionOpenMessageInBrowser(); } }); userCenter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); actionUserCenter(); } }); completeInitDialogMode(alertDialog, dialogView); alertDialog.show(); } }
From source file:biz.bokhorst.xprivacy.ActivityMain.java
@SuppressLint("InflateParams") private void optionTemplate() { final int userId = Util.getUserId(Process.myUid()); // Build view LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.template, null); final Spinner spTemplate = (Spinner) view.findViewById(R.id.spTemplate); Button btnRename = (Button) view.findViewById(R.id.btnRename); ExpandableListView elvTemplate = (ExpandableListView) view.findViewById(R.id.elvTemplate); // Template selector final SpinnerAdapter spAdapter = new SpinnerAdapter(this, android.R.layout.simple_spinner_item); spAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); String defaultName = PrivacyManager.getSetting(userId, Meta.cTypeTemplateName, "0", getString(R.string.title_default)); spAdapter.add(defaultName);//from w w w .j ava 2 s . c o m for (int i = 1; i <= 4; i++) { String alternateName = PrivacyManager.getSetting(userId, Meta.cTypeTemplateName, Integer.toString(i), getString(R.string.title_alternate) + " " + i); spAdapter.add(alternateName); } spTemplate.setAdapter(spAdapter); // Template definition final TemplateListAdapter templateAdapter = new TemplateListAdapter(this, view, R.layout.templateentry); elvTemplate.setAdapter(templateAdapter); elvTemplate.setGroupIndicator(null); spTemplate.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { templateAdapter.notifyDataSetChanged(); } @Override public void onNothingSelected(AdapterView<?> arg0) { templateAdapter.notifyDataSetChanged(); } }); btnRename.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (Util.hasProLicense(ActivityMain.this) == null) { // Redirect to pro page Util.viewUri(ActivityMain.this, cProUri); return; } final int templateId = spTemplate.getSelectedItemPosition(); if (templateId == AdapterView.INVALID_POSITION) return; AlertDialog.Builder dlgRename = new AlertDialog.Builder(spTemplate.getContext()); dlgRename.setTitle(R.string.title_rename); final String original = (templateId == 0 ? getString(R.string.title_default) : getString(R.string.title_alternate) + " " + templateId); dlgRename.setMessage(original); final EditText input = new EditText(spTemplate.getContext()); dlgRename.setView(input); dlgRename.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String name = input.getText().toString(); if (TextUtils.isEmpty(name)) { PrivacyManager.setSetting(userId, Meta.cTypeTemplateName, Integer.toString(templateId), null); name = original; } else { PrivacyManager.setSetting(userId, Meta.cTypeTemplateName, Integer.toString(templateId), name); } spAdapter.remove(spAdapter.getItem(templateId)); spAdapter.insert(name, templateId); spAdapter.notifyDataSetChanged(); } }); dlgRename.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing } }); dlgRename.create().show(); } }); // Build dialog AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle(R.string.menu_template); alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher)); alertDialogBuilder.setView(view); alertDialogBuilder.setPositiveButton(getString(R.string.msg_done), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Do nothing } }); // Show dialog AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); }
From source file:info.guardianproject.otr.app.im.app.NewChatActivity.java
private void setupAccountSpinner(Spinner spinner) { final Uri uri = Imps.Provider.CONTENT_URI_WITH_ACCOUNT; final Cursor cursorProviders = managedQuery(uri, PROVIDER_PROJECTION, Imps.Provider.CATEGORY + "=?" + " AND " + Imps.Provider.ACTIVE_ACCOUNT_USERNAME + " NOT NULL" /* selection */, new String[] { ImApp.IMPS_CATEGORY } /* selection args */, Imps.Provider.DEFAULT_SORT_ORDER); SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_dropdown_item, cursorProviders, new String[] { Imps.Provider.ACTIVE_ACCOUNT_USERNAME }, new int[] { android.R.id.text1 }); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); if (cursorProviders.getCount() > 0) { cursorProviders.moveToFirst();//from w ww .ja v a 2s .c om mLastProviderId = cursorProviders.getLong(PROVIDER_ID_COLUMN); mLastAccountId = cursorProviders.getLong(ACTIVE_ACCOUNT_ID_COLUMN); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { cursorProviders.moveToPosition(arg2); mLastProviderId = cursorProviders.getLong(PROVIDER_ID_COLUMN); mLastAccountId = cursorProviders.getLong(ACTIVE_ACCOUNT_ID_COLUMN); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); } else { spinner.setVisibility(View.GONE); } }