List of usage examples for android.widget Spinner setAdapter
@Override public void setAdapter(SpinnerAdapter adapter)
From source file:cl.gisred.android.MicroMedidaActivity.java
public void setActionsFormDenuncio(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 . ja v a 2 s .c o m v.setMinimumWidth(widthScale); formCrear.setTitle(sNombre); formCrear.setContentView(v); idResLayoutSelect = idRes; Spinner spEstado = (Spinner) v.findViewById(R.id.spinnerEstado); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayEstado); spEstado.setAdapter(adapter); Spinner spTipoEdif = (Spinner) v.findViewById(R.id.spinnerTipoEdific); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayTipoEdif); spTipoEdif.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); setValueToAsoc(getLayoutContenedor(view)); } }); ImageButton btnIdentDireccion = (ImageButton) v.findViewById(R.id.btnDireccion); btnIdentDireccion.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { formCrear.hide(); bMapTap = true; bCallOut = true; oLySelectAsoc = LyAddDireccion; oLyExistAsoc = LyDIRECCIONES; oLyExistAsoc.setVisible(true); myMapView.zoomToScale(ldm.getPoint(), oLyExistAsoc.getMinScale() * 0.9); setValueToAsoc(getLayoutContenedor(v)); } }); 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.example.android.lightcontrol.MainActivity.java
private void fadetime() { LayoutInflater inflater = LayoutInflater.from(this); final View v = inflater.inflate(R.layout.fadetime, null); final AlertDialog.Builder dialog = new AlertDialog.Builder(this); Spinner fade_time = (Spinner) v.findViewById(R.id.fade_time); ArrayAdapter<String> fadetimelist; final String[] fadetime = { "No Fade Time", "0.7sec", "1sec", "1.4sec", "2sec", "2.8sec", "4sec" }; fadetimelist = new ArrayAdapter<String>(this, R.layout.my_spinner, fadetime); fade_time.setAdapter(fadetimelist); fade_time.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override//from w ww . j a va 2 s . c om public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { if (fadetime[i].equals("No Fade Time")) { GlobalVariable.fade_time = "00"; GlobalVariable.t = 50; } if (fadetime[i].equals("0.7sec")) { GlobalVariable.fade_time = "01"; GlobalVariable.t = 700; } if (fadetime[i].equals("1sec")) { GlobalVariable.fade_time = "02"; GlobalVariable.t = 1000; } if (fadetime[i].equals("1.4sec")) { GlobalVariable.fade_time = "03"; GlobalVariable.t = 1400; } if (fadetime[i].equals("2sec")) { GlobalVariable.fade_time = "04"; GlobalVariable.t = 2000; } if (fadetime[i].equals("2.8sec")) { GlobalVariable.fade_time = "05"; GlobalVariable.t = 2800; } if (fadetime[i].equals("4sec")) { GlobalVariable.fade_time = "06"; GlobalVariable.t = 4000; } } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); dialog.setCancelable(false); dialog.setTitle(R.string.about_title); dialog.setView(v); dialog.setPositiveButton(R.string.ok_label_1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialoginterface, int i) { //aa 55 07 01 00 00 00 de 00 xx chk String send_mode_1 = GlobalVariable.by1_AA + GlobalVariable.by2_55 + "07" + GlobalVariable.by4_01 + "00" + "00" + "00" + "de" + "00" + GlobalVariable.fade_time; int checksum = ((Integer.parseInt(GlobalVariable.by1_AA, 16)) + (Integer.parseInt(GlobalVariable.by2_55, 16)) + (Integer.parseInt("07", 16)) + (Integer.parseInt(GlobalVariable.by4_01, 16)) + (Integer.parseInt("de", 16)) // + (Integer.parseInt(GlobalVariable.OnSpinnerItemSelectedOfShort.substring(0, 2), 16)) // + (Integer.parseInt(GlobalVariable.OnSpinnerItemSelectedOfShort.substring(2, 4), 16)) + (Integer.parseInt(GlobalVariable.fade_time, 16))) % 256; if (D) Log.e(TAG, "checksum" + checksum); String send_group_on1 = send_mode_1 + Integer.toHexString(checksum); if (D) Log.e(TAG, "send_group_on1" + send_group_on1); sendMessage(send_group_on1); try { Thread.sleep(150); } catch (InterruptedException ignored) { } } }); dialog.show(); }
From source file:cl.gisred.android.MicroMedidaActivity.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 a 2 s . c o m v.setMinimumWidth(widthScale); formCrear.setTitle(sNombre); formCrear.setContentView(v); idResLayoutSelect = idRes; Spinner spMarcaMed = (Spinner) v.findViewById(R.id.spinnerMarcaMed); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayMarcaMed); spMarcaMed.setAdapter(adapter); Spinner spObservacion = (Spinner) v.findViewById(R.id.spinnerObservacion); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayObservacion); spObservacion.setAdapter(adapter); Spinner spFaseConex = (Spinner) v.findViewById(R.id.spinnerFaseCon); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayfaseConex); spFaseConex.setAdapter(adapter); ImageButton btnDireccion = (ImageButton) v.findViewById(R.id.btnAddress); btnDireccion.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { formCrear.hide(); bMapTap = true; bCallOut = true; oLySelectAsoc = LyAddDireccion; oLyExistAsoc = LyDIRECCIONES; oLyExistAsoc.setVisible(true); setValueToAsoc(getLayoutContenedor(v)); } }); 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); setValueToAsoc(getLayoutContenedor(view)); } }); ImageButton btnTramoBt = (ImageButton) v.findViewById(R.id.btnTramoBt); btnTramoBt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { formCrear.hide(); bMapTap = true; bCallOut = true; nIndentify = 2; //2 = valor para tramo oLySelectAsoc = LyAsocTramo; setValueToAsoc(getLayoutContenedor(v)); } }); 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:universe.constellation.orion.viewer.OrionViewerActivity.java
public void initZoomScreen() { //zoom screen final Spinner sp = (Spinner) findMyViewById(R.id.zoom_spinner); final EditText zoomText = (EditText) findMyViewById(R.id.zoom_picker_message); final SeekBar zoomSeek = (SeekBar) findMyViewById(R.id.zoom_picker_seeker); if (zoomSeek != null) { zoomSeek.setMax(300);/*from ww w.ja v a2s . c o m*/ zoomSeek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (zoomInternal != 1) { zoomText.setText("" + progress); if (sp.getSelectedItemPosition() != 0) { int oldInternal = zoomInternal; zoomInternal = 2; sp.setSelection(0); zoomInternal = oldInternal; } } } public void onStartTrackingTouch(SeekBar seekBar) { } public void onStopTrackingTouch(SeekBar seekBar) { } }); } getSubscriptionManager().addDocListeners(new DocumentViewAdapter() { @Override public void documentOpened(Controller controller) { updateZoom(); } }); final ImageButton zplus = (ImageButton) findMyViewById(R.id.zoom_picker_plus); zplus.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { zoomSeek.incrementProgressBy(1); } }); final ImageButton zminus = (ImageButton) findMyViewById(R.id.zoom_picker_minus); zminus.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (zoomSeek.getProgress() != 0) { zoomSeek.incrementProgressBy(-1); } } }); ImageButton closeZoomPeeker = (ImageButton) findMyViewById(R.id.zoom_picker_close); closeZoomPeeker.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //main menu onAnimatorCancel(); //updateZoom(); } }); ImageButton zoom_preview = (ImageButton) findMyViewById(R.id.zoom_preview); zoom_preview.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { onApplyAction(); int index = sp.getSelectedItemPosition(); controller.changeZoom(index == 0 ? (int) (Float.parseFloat(zoomText.getText().toString()) * 100) : -1 * (index - 1)); updateZoom(); } }); sp.setAdapter(new MyArrayAdapter()); sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { boolean disable = position != 0; int oldZoomInternal = zoomInternal; if (zoomInternal != 2) { zoomInternal = 1; if (disable) { zoomText.setText((String) parent.getAdapter().getItem(position)); } else { zoomText.setText("" + ((int) (controller.getCurrentPageZoom() * 10000)) / 100f); zoomSeek.setProgress((int) (controller.getCurrentPageZoom() * 100)); } zoomInternal = oldZoomInternal; } zminus.setVisibility(disable ? View.GONE : View.VISIBLE); zplus.setVisibility(disable ? View.GONE : View.VISIBLE); zoomText.setFocusable(!disable); zoomText.setFocusableInTouchMode(!disable); final LinearLayout parent1 = (LinearLayout) zoomText.getParent(); parent1.post(new Runnable() { @Override public void run() { parent1.requestLayout(); } }); } public void onNothingSelected(AdapterView<?> parent) { //To change body of implemented methods use File | Settings | File Templates. } }); //by width sp.setSelection(1); }
From source file:com.example.android.lightcontrol.MainActivity.java
private void theme_to_who() { LayoutInflater inflater = LayoutInflater.from(this); final View v = inflater.inflate(R.layout.theme_to_who, null); final AlertDialog.Builder dialog = new AlertDialog.Builder(this); Spinner theme_to_who = (Spinner) v.findViewById(R.id.theme_to_who); final Spinner theme_to_area1 = (Spinner) v.findViewById(R.id.area_1); final Spinner theme_to_area2 = (Spinner) v.findViewById(R.id.area_2); final TextView region1 = (TextView) v.findViewById(R.id.textView16); final TextView region2 = (TextView) v.findViewById(R.id.textView17); ArrayAdapter<String> arr_theme_to_who_list; ArrayAdapter<String> arr_theme_to_area1_list; ArrayAdapter<String> arr_theme_to_area2_list; final String[] theme_to_who_list = { "All Lights", "Group" }; final String[] theme_to_area1_list = { "Group 1" }; final String[] theme_to_area2_list = { "Group 2" }; arr_theme_to_who_list = new ArrayAdapter<String>(this, R.layout.my_spinner, theme_to_who_list); theme_to_who.setAdapter(arr_theme_to_who_list); arr_theme_to_area1_list = new ArrayAdapter<String>(this, R.layout.my_spinner, theme_to_area1_list); theme_to_area1.setAdapter(arr_theme_to_area1_list); arr_theme_to_area2_list = new ArrayAdapter<String>(this, R.layout.my_spinner, theme_to_area2_list); theme_to_area2.setAdapter(arr_theme_to_area2_list); theme_to_who.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override// www.j av a 2 s .c o m public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { if (theme_to_who_list[i].equals("All Lights")) { theme_to_area1.setVisibility(View.INVISIBLE); theme_to_area2.setVisibility(View.INVISIBLE); region1.setVisibility(View.INVISIBLE); region2.setVisibility(View.INVISIBLE); GlobalVariable.Theme_to_group_or_all = "ff"; GlobalVariable.Theme_to_area1_group_8X = ""; GlobalVariable.Theme_to_area2_group_8X = ""; } if (theme_to_who_list[i].equals("Group")) { GlobalVariable.Theme_to_group_or_all = "8"; theme_to_area1.setVisibility(View.VISIBLE); theme_to_area2.setVisibility(View.VISIBLE); region1.setVisibility(View.VISIBLE); region2.setVisibility(View.VISIBLE); } } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); theme_to_area1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { if (theme_to_area1_list[i].equals("Group 1")) { GlobalVariable.Theme_to_area1_group_8X = "1"; } } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); theme_to_area2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { if (theme_to_area2_list[i].equals("Group 2")) { GlobalVariable.Theme_to_area2_group_8X = "3"; } } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); dialog.setCancelable(false); dialog.setTitle(R.string.about_title); dialog.setView(v); dialog.setPositiveButton(R.string.ok_label_1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialoginterface, int i) { } }); dialog.show(); }
From source file:cl.gisred.android.InspActivity.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;/* w w w .j a va 2 s . c o m*/ v.setMinimumWidth(widthScale); formCrear.setTitle(sNombre); formCrear.setContentView(v); idResLayoutSelect = idRes; boolean bSpinnerMedidor = idRes == R.layout.form_inspec_telemedida; Spinner spTipoFase = (Spinner) v.findViewById(R.id.spinnerFase); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayTipoFaseInsp); spTipoFase.setAdapter(adapter); Spinner spTipoMarca = (Spinner) v.findViewById(R.id.spinnerTipo); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, (bSpinnerMedidor) ? arrayTipoMarcaTM : arrayTipoMarca); spTipoMarca.setAdapter(adapter); Spinner spMarca = (Spinner) v.findViewById(R.id.spinnerMarca); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, (bSpinnerMedidor) ? arrayMarcaTM : arrayMarca); spMarca.setAdapter(adapter); final GisEditText txtPoste = (GisEditText) v.findViewById(R.id.txtPoste); final EditText txtRotulo = (EditText) v.findViewById(R.id.txtRotulo); txtPoste.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { if (i2 > 1) { if (bInspRotulo) { txtRotulo.setText(charSequence); if (!txtRotulo.hasFocus()) txtRotulo.requestFocus(); bInspRotulo = false; txtPoste.setText(String.format("%s", txtPoste.getIdObjeto())); } else bInspRotulo = true; } } @Override public void afterTextChanged(Editable editable) { } }); 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); setValueToAsoc(getLayoutContenedor(view)); } }); final EditText txtFecha = (EditText) v.findViewById(R.id.txtFechaEjec); txtFecha.setText(dateFormatter.format(Calendar.getInstance().getTime())); txtFecha.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { datePickerDialog.show(); } }); Calendar newCalendar = Calendar.getInstance(); datePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { Calendar newDate = Calendar.getInstance(); newDate.set(year, monthOfYear, dayOfMonth); txtFecha.setText(dateFormatter.format(newDate.getTime())); } }, newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH)); final EditText txtHoraIni = (EditText) v.findViewById(R.id.txtHoraIni); txtHoraIni.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { timePickerDialog.show(); txtHora = txtHoraIni; } }); final EditText txtHoraFin = (EditText) v.findViewById(R.id.txtHoraFin); txtHoraFin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { timePickerDialog.show(); txtHora = txtHoraFin; } }); timePickerDialog = new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) { txtHora.setText(String.format(Locale.getDefault(), "%02d:%02d", selectedHour, selectedMinute)); } }, newCalendar.get(Calendar.HOUR), newCalendar.get(Calendar.MINUTE), false); final EditText txtEjecutor = (EditText) v.findViewById(R.id.txtEjecutor); txtEjecutor.setText(Util.getUserWithoutDomain(usuar)); Spinner spFirmante = (Spinner) v.findViewById(R.id.spinnerFirmante); if (spFirmante != null) { adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayFirmante); spFirmante.setAdapter(adapter); spFirmante.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { setRequerido(view, R.id.txtRutInst, i > 0); setRequerido(view, R.id.txtNomInst, i > 0); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); } Spinner spTipoMarcaRet = (Spinner) v.findViewById(R.id.spinnerTipoRet); if (spTipoMarcaRet != null) { adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayTipoMarca); spTipoMarcaRet.setAdapter(adapter); } Spinner spMarcaRet = (Spinner) v.findViewById(R.id.spinnerMarcaRet); if (spMarcaRet != null) { adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayMarca); spMarcaRet.setAdapter(adapter); } final CheckBox chkInspFallo = (CheckBox) v.findViewById(R.id.chkInspFallo); if (chkInspFallo != null) { chkInspFallo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { bFallo = chkInspFallo.isChecked(); modoFallo(v, bFallo); } }); } ImageButton btnClose = (ImageButton) v.findViewById(R.id.btnCancelar); btnClose.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { cerrarFormCrear(false, v, 0); } }); ImageButton btnOk = (ImageButton) v.findViewById(R.id.btnConfirmar); btnOk.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { cerrarFormCrear(true, v, idRes); } }); imgFirmaTec = (ImageView) v.findViewById(R.id.imgFirmaTec); imgFirmaInsp = (ImageView) v.findViewById(R.id.imgFirmaIns); imgPhoto1 = (ImageView) v.findViewById(R.id.imgPhoto1); imgPhoto2 = (ImageView) v.findViewById(R.id.imgPhoto2); imgPhoto3 = (ImageView) v.findViewById(R.id.imgPhoto3); final ImageButton btnFirmaTec = (ImageButton) v.findViewById(R.id.btnFirmaTec); if (btnFirmaTec != null && imgFirmaTec != null) { btnFirmaTec.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { imgTemp = imgFirmaTec; DialogoFirma oDialog = new DialogoFirma(); oDialog.show(getFragmentManager(), "tagFirma"); } }); imgFirmaTec.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { crearDialogoImg((ImageView) v).show(); return false; } }); } final ImageButton btnFirmaInsp = (ImageButton) v.findViewById(R.id.btnFirmaIns); if (btnFirmaInsp != null && imgFirmaInsp != null) { btnFirmaInsp.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { imgTemp = imgFirmaInsp; DialogoFirma oDialog = new DialogoFirma(); oDialog.show(getFragmentManager(), "tagFirma"); } }); imgFirmaInsp.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { crearDialogoImg((ImageView) v).show(); return false; } }); } imgPhoto1.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { crearDialogoImg((ImageView) v).show(); return false; } }); imgPhoto2.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { crearDialogoImg((ImageView) v).show(); return false; } }); imgPhoto3.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { crearDialogoImg((ImageView) v).show(); return false; } }); ImageButton btnPhoto1 = (ImageButton) v.findViewById(R.id.btnPhoto1); btnPhoto1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { imgTemp = imgPhoto1; if (Build.VERSION.SDK_INT >= 22) verifCamara("foto1"); else tomarFoto("foto1"); } }); ImageButton btnPhoto2 = (ImageButton) v.findViewById(R.id.btnPhoto2); btnPhoto2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { imgTemp = imgPhoto2; if (Build.VERSION.SDK_INT >= 22) verifCamara("foto2"); else tomarFoto("foto2"); } }); ImageButton btnPhoto3 = (ImageButton) v.findViewById(R.id.btnPhoto3); btnPhoto3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { imgTemp = imgPhoto3; if (Build.VERSION.SDK_INT >= 22) verifCamara("foto3"); else tomarFoto("foto3"); } }); ImageButton btnFile1 = (ImageButton) v.findViewById(R.id.btnFile1); btnFile1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { imgTemp = imgPhoto1; if (Build.VERSION.SDK_INT >= 22) verifAccesoExterno("foto1"); else imageGallery("foto1"); } }); ImageButton btnFile2 = (ImageButton) v.findViewById(R.id.btnFile2); btnFile2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { imgTemp = imgPhoto2; if (Build.VERSION.SDK_INT >= 22) verifAccesoExterno("foto2"); else imageGallery("foto2"); } }); ImageButton btnFile3 = (ImageButton) v.findViewById(R.id.btnFile3); btnFile3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { imgTemp = imgPhoto3; if (Build.VERSION.SDK_INT >= 22) verifAccesoExterno("foto3"); else imageGallery("foto3"); } }); arrayTouchs = new ArrayList<>(); //setEnabledDialog(false); formCrear.show(); dialogCur = formCrear; }
From source file:cl.gisred.android.InspActivity.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);/* w w w. j av a 2 s. c o 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); 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 != 4) { if (llDireccion != null) llDireccion.setVisibility(View.GONE); if (llBuscar != null) llBuscar.setVisibility(View.VISIBLE); } else { if (llDireccion != null) llDireccion.setVisibility(View.VISIBLE); if (llBuscar != null) llBuscar.setVisibility(View.GONE); } } @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); 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 > 1) txtBusqueda = eSearch.getText().toString(); else txtBusqueda = Util.extraerNum(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 // TODO Asignar a res values o strings 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; } } } }); dialogBusqueda.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); dialogBusqueda.show(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public void promptImageName(final Activity activity, String hd) { final String hd_string = hd; final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Image Name"); RelativeLayout mLayout = new RelativeLayout(this); mLayout.setId(12222);//from ww w . j a v a2 s.c o m EditText imageNameView = new EditText(activity); imageNameView.setEnabled(true); imageNameView.setVisibility(View.VISIBLE); imageNameView.setId(201012010); imageNameView.setSingleLine(); RelativeLayout.LayoutParams searchViewParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); mLayout.addView(imageNameView, searchViewParams); final Spinner size = new Spinner(this); RelativeLayout.LayoutParams setPlusParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); size.setId(201012044); String[] arraySpinner = new String[7]; for (int i = 0; i < arraySpinner.length; i++) { if (i < 5) { arraySpinner[i] = (i + 1) + " GB"; } } arraySpinner[5] = "10 GB"; arraySpinner[6] = "20 GB"; ArrayAdapter sizeAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, arraySpinner); sizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); size.setAdapter(sizeAdapter); setPlusParams.addRule(RelativeLayout.BELOW, imageNameView.getId()); mLayout.addView(size, setPlusParams); // TODO: Not working for now // final TextView preallocText = new TextView(this); // preallocText.setText("Preallocate? "); // preallocText.setTextSize(15); // RelativeLayout.LayoutParams preallocTParams = new // RelativeLayout.LayoutParams( // RelativeLayout.LayoutParams.WRAP_CONTENT, // RelativeLayout.LayoutParams.WRAP_CONTENT); // preallocTParams.addRule(RelativeLayout.BELOW, size.getId()); // mLayout.addView(preallocText, preallocTParams); // preallocText.setId(64512044); // // final CheckBox prealloc = new CheckBox(this); // RelativeLayout.LayoutParams preallocParams = new // RelativeLayout.LayoutParams( // RelativeLayout.LayoutParams.WRAP_CONTENT, // RelativeLayout.LayoutParams.WRAP_CONTENT); // preallocParams.addRule(RelativeLayout.BELOW, size.getId()); // preallocParams.addRule(RelativeLayout.RIGHT_OF, // preallocText.getId()); // preallocParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, // preallocText.getId()); // mLayout.addView(prealloc, preallocParams); // prealloc.setId(64512344); alertDialog.setView(mLayout); final Handler handler = this.handler; // alertDialog.setMessage(body); alertDialog.setButton("Create", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { int sizeSel = size.getSelectedItemPosition(); String templateImage = "hd1g.qcow2"; if (sizeSel < 5) { templateImage = "hd" + (sizeSel + 1) + "g.qcow2"; } else if (sizeSel == 5) { templateImage = "hd10g.qcow2"; } else if (sizeSel == 6) { templateImage = "hd20g.qcow2"; } // UIUtils.log("Searching..."); EditText a = (EditText) alertDialog.findViewById(201012010); progDialog = ProgressDialog.show(activity, "Please Wait", "Creating HD Image...", true); // CreateImage createImg = new // CreateImage(a.getText().toString(), // hd_string, sizeInt, prealloc.isChecked()); // CreateImage createImg = new CreateImage(a.getText().toString(), // hd_string, sizeInt, false); // createImg.execute(); String image = a.getText().toString(); if (!image.endsWith(".qcow2")) { image += ".qcow2"; } createImg(templateImage, image, hd_string); } }); alertDialog.show(); }
From source file:org.thoughtland.xlocation.ActivityShare.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Check privacy service client if (!PrivacyService.checkClient()) return;/*from w w w. j a v a2s . c o m*/ // Get data int userId = Util.getUserId(Process.myUid()); final Bundle extras = getIntent().getExtras(); final String action = getIntent().getAction(); final int[] uids = (extras != null && extras.containsKey(cUidList) ? extras.getIntArray(cUidList) : new int[0]); final String restrictionName = (extras != null ? extras.getString(cRestriction) : null); int choice = (extras != null && extras.containsKey(cChoice) ? extras.getInt(cChoice) : -1); if (action.equals(ACTION_EXPORT)) mFileName = (extras != null && extras.containsKey(cFileName) ? extras.getString(cFileName) : null); // License check if (action.equals(ACTION_IMPORT) || action.equals(ACTION_EXPORT)) { if (!Util.isProEnabled() && Util.hasProLicense(this) == null) { Util.viewUri(this, ActivityMain.cProUri); finish(); return; } } else if (action.equals(ACTION_FETCH) || (action.equals(ACTION_TOGGLE) && uids.length > 1)) { if (Util.hasProLicense(this) == null) { Util.viewUri(this, ActivityMain.cProUri); finish(); return; } } // Registration check if (action.equals(ACTION_SUBMIT) && !registerDevice(this)) { finish(); return; } // Check whether we need a user interface if (extras != null && extras.containsKey(cInteractive) && extras.getBoolean(cInteractive, false)) mInteractive = true; // Set layout setContentView(R.layout.sharelist); // Reference controls final TextView tvDescription = (TextView) findViewById(R.id.tvDescription); final ScrollView svToggle = (ScrollView) findViewById(R.id.svToggle); final RadioGroup rgToggle = (RadioGroup) findViewById(R.id.rgToggle); final Spinner spRestriction = (Spinner) findViewById(R.id.spRestriction); RadioButton rbClear = (RadioButton) findViewById(R.id.rbClear); RadioButton rbTemplateFull = (RadioButton) findViewById(R.id.rbTemplateFull); RadioButton rbODEnable = (RadioButton) findViewById(R.id.rbEnableOndemand); RadioButton rbODDisable = (RadioButton) findViewById(R.id.rbDisableOndemand); final Spinner spTemplate = (Spinner) findViewById(R.id.spTemplate); final CheckBox cbClear = (CheckBox) findViewById(R.id.cbClear); final Button btnOk = (Button) findViewById(R.id.btnOk); final Button btnCancel = (Button) findViewById(R.id.btnCancel); // Set title if (action.equals(ACTION_TOGGLE)) { mActionId = R.string.menu_toggle; setTitle(R.string.menu_toggle); } else if (action.equals(ACTION_IMPORT)) { mActionId = R.string.menu_import; setTitle(R.string.menu_import); } else if (action.equals(ACTION_EXPORT)) { mActionId = R.string.menu_export; setTitle(R.string.menu_export); } else if (action.equals(ACTION_FETCH)) { mActionId = R.string.menu_fetch; setTitle(R.string.menu_fetch); } else if (action.equals(ACTION_SUBMIT)) { mActionId = R.string.menu_submit; setTitle(R.string.menu_submit); } else { finish(); return; } // Get localized restriction name List<String> listRestrictionName = new ArrayList<String>( PrivacyManager.getRestrictions(this).navigableKeySet()); listRestrictionName.add(0, getString(R.string.menu_all)); // Build restriction adapter SpinnerAdapter saRestriction = new SpinnerAdapter(this, android.R.layout.simple_spinner_item); saRestriction.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); saRestriction.addAll(listRestrictionName); // Setup restriction spinner int pos = 0; if (restrictionName != null) for (String restriction : PrivacyManager.getRestrictions(this).values()) { pos++; if (restrictionName.equals(restriction)) break; } spRestriction.setAdapter(saRestriction); spRestriction.setSelection(pos); // Build template adapter SpinnerAdapter spAdapter = new SpinnerAdapter(this, android.R.layout.simple_spinner_item); spAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spAdapter.add(getString(R.string.title_default)); for (int i = 1; i <= 4; i++) spAdapter.add(getString(R.string.title_alternate) + " " + i); spTemplate.setAdapter(spAdapter); // Build application list AppListTask appListTask = new AppListTask(); appListTask.executeOnExecutor(mExecutor, uids); // Import/export filename if (action.equals(ACTION_EXPORT) || action.equals(ACTION_IMPORT)) { // Check for availability of sharing intent Intent file = new Intent(Intent.ACTION_GET_CONTENT); file.setType("file/*"); boolean hasIntent = Util.isIntentAvailable(ActivityShare.this, file); // Get file name if (mFileName == null) if (action.equals(ACTION_EXPORT)) { String packageName = null; if (uids.length == 1) try { ApplicationInfoEx appInfo = new ApplicationInfoEx(this, uids[0]); packageName = appInfo.getPackageName().get(0); } catch (Throwable ex) { Util.bug(null, ex); } mFileName = getFileName(this, hasIntent, packageName); } else mFileName = (hasIntent ? null : getFileName(this, false, null)); if (mFileName == null) fileChooser(); else showFileName(); if (action.equals(ACTION_IMPORT)) cbClear.setVisibility(View.VISIBLE); } else if (action.equals(ACTION_FETCH)) { tvDescription.setText(getBaseURL()); cbClear.setVisibility(View.VISIBLE); } else if (action.equals(ACTION_TOGGLE)) { tvDescription.setText(R.string.menu_toggle); spRestriction.setVisibility(View.VISIBLE); svToggle.setVisibility(View.VISIBLE); // Listen for radio button rgToggle.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { btnOk.setEnabled(checkedId >= 0); spRestriction.setVisibility( checkedId == R.id.rbEnableOndemand || checkedId == R.id.rbDisableOndemand ? View.GONE : View.VISIBLE); spTemplate.setVisibility(checkedId == R.id.rbTemplateCategory || checkedId == R.id.rbTemplateFull || checkedId == R.id.rbTemplateMergeSet || checkedId == R.id.rbTemplateMergeReset ? View.VISIBLE : View.GONE); } }); boolean ondemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true); rbODEnable.setVisibility(ondemand ? View.VISIBLE : View.GONE); rbODDisable.setVisibility(ondemand ? View.VISIBLE : View.GONE); if (choice == CHOICE_CLEAR) rbClear.setChecked(true); else if (choice == CHOICE_TEMPLATE) rbTemplateFull.setChecked(true); } else tvDescription.setText(getBaseURL()); if (mInteractive) { // Enable ok // (showFileName does this for export/import) if (action.equals(ACTION_SUBMIT) || action.equals(ACTION_FETCH)) btnOk.setEnabled(true); // Listen for ok btnOk.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { btnOk.setEnabled(false); // Toggle if (action.equals(ACTION_TOGGLE)) { mRunning = true; for (int i = 0; i < rgToggle.getChildCount(); i++) ((RadioButton) rgToggle.getChildAt(i)).setEnabled(false); int pos = spRestriction.getSelectedItemPosition(); String restrictionName = (pos == 0 ? null : (String) PrivacyManager.getRestrictions(ActivityShare.this).values().toArray()[pos - 1]); new ToggleTask().executeOnExecutor(mExecutor, restrictionName); // Import } else if (action.equals(ACTION_IMPORT)) { mRunning = true; cbClear.setEnabled(false); new ImportTask().executeOnExecutor(mExecutor, new File(mFileName), cbClear.isChecked()); } // Export else if (action.equals(ACTION_EXPORT)) { mRunning = true; new ExportTask().executeOnExecutor(mExecutor, new File(mFileName)); // Fetch } else if (action.equals(ACTION_FETCH)) { if (uids.length > 0) { mRunning = true; cbClear.setEnabled(false); new FetchTask().executeOnExecutor(mExecutor, cbClear.isChecked()); } } // Submit else if (action.equals(ACTION_SUBMIT)) { if (uids.length > 0) { if (uids.length <= cSubmitLimit) { mRunning = true; new SubmitTask().executeOnExecutor(mExecutor); } else { String message = getString(R.string.msg_limit, cSubmitLimit + 1); Toast.makeText(ActivityShare.this, message, Toast.LENGTH_LONG).show(); btnOk.setEnabled(false); } } } } }); } else btnOk.setEnabled(false); // Listen for cancel btnCancel.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { if (mRunning) { mAbort = true; Toast.makeText(ActivityShare.this, getString(R.string.msg_abort), Toast.LENGTH_LONG).show(); } else finish(); } }); }