List of usage examples for android.widget Spinner setAdapter
@Override public void setAdapter(SpinnerAdapter adapter)
From source file:com.RSMSA.policeApp.OffenceReportForm.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_report_offence); sharedpreferences = getSharedPreferences(MyPREF, Context.MODE_PRIVATE); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);// w w w . j av a 2 s . co m getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setTranslucentStatus(true); } SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); ColorDrawable colorDrawable = new ColorDrawable(getResources().getColor(R.color.blue_900)); tintManager.setTintDrawable(colorDrawable); RelativeLayout inputs = (RelativeLayout) findViewById(R.id.inputs); plateNumberEdit = (EditText) findViewById(R.id.plate_number_edit_text); licenceNumberEdit = (EditText) findViewById(R.id.licence_number_edit_text); final Bundle bundle = getIntent().getExtras(); namePassed = bundle.getString("name"); dLicense = bundle.getString("licence_number"); plateNumberObtained = bundle.getString("plate_number"); driverUid = bundle.getString("driverUid"); vehicleUid = bundle.getString("vehicleUid"); try { invalidLicence = bundle.getString("invalidLicence"); expiredInsuarance = bundle.getString("expiredInsuarance"); } catch (NullPointerException e) { } if (dLicense.equals("") || dLicense == null) { licenceNumberEdit.setVisibility(View.VISIBLE); } else if (plateNumberObtained.equals("") || plateNumberObtained == null) { plateNumberEdit.setVisibility(View.VISIBLE); } submit = (TextView) findViewById(R.id.submit_text); plateNo = (TextView) findViewById(R.id.plate_no_); chargesAcceptance = (TextView) findViewById(R.id.charges_acceptance); chargesAcceptance.setTypeface(MainOffence.Roboto_Regular); offensesCommittedTextview = (TextView) findViewById(R.id.offences_committed_title); offensesCommittedTextview.setTypeface(MainOffence.Roboto_BoldCondensed); ChargesAcceptanceTitle = (TextView) findViewById(R.id.charges_acceptance_title); paymentMethodTitle = (TextView) findViewById(R.id.payment_method_title); PaymentTitle = (TextView) findViewById(R.id.payment_title); ChargesAcceptanceTitle.setTypeface(MainOffence.Roboto_BoldCondensed); paymentMethodTitle.setTypeface(MainOffence.Roboto_BoldCondensed); PaymentTitle.setTypeface(MainOffence.Roboto_BoldCondensed); offencesCostTitle = (TextView) findViewById(R.id.offences_cost_title); offencesCostTitle.setTypeface(MainOffence.Roboto_BoldCondensed); submitText = (TextView) findViewById(R.id.submit_text); license = (TextView) findViewById(R.id.license); license.setText(dLicense); report = (RelativeLayout) findViewById(R.id.report); summary = (RelativeLayout) findViewById(R.id.summary); submit_layout = (RelativeLayout) findViewById(R.id.submit_layout); submit_layout1 = (RelativeLayout) findViewById(R.id.submit_layout1); submit_layout1.setVisibility(View.GONE); progressBar = (ProgressBar) findViewById(R.id.pbar_report); TextView driverName = (TextView) findViewById(R.id.driver_name); driverName.setTypeface(MainOffence.Roboto_BoldCondensed); TextView plateNumberTitle = (TextView) findViewById(R.id.plate_no_title_); plateNumberTitle.setTypeface(MainOffence.Roboto_BoldCondensed); TextView driverLicense = (TextView) findViewById(R.id.driver_license); driverLicense.setTypeface(MainOffence.Roboto_BoldCondensed); RelativeLayout OffenseType = (RelativeLayout) findViewById(R.id.offense_type); OffenseType.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(OffenceReportForm.this, OffenseListActivity.class); OffenceReportForm.this.startActivityForResult(intent, REPORT_RESULT); } }); offense_type_text = (TextView) findViewById(R.id.offense_type_text); offencesSelectedTextView = (TextView) findViewById(R.id.offence_list); offensesCommittedTextview = (TextView) findViewById(R.id.offences_committed); TextView name = (TextView) findViewById(R.id.name); name.setText(namePassed); final RadioButton court = (RadioButton) findViewById(R.id.court); court.setTypeface(MainOffence.Roboto_BoldCondensed); final RadioButton guilty = (RadioButton) findViewById(R.id.guilty); guilty.setTypeface(MainOffence.Roboto_BoldCondensed); guilty.setChecked(true); court.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b == true) { guilty.setChecked(false); commit = false; } } }); guilty.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b == true) { court.setChecked(false); commit = true; } } }); final String[] paymentMethodsArray = this.getResources().getStringArray(R.array.payment_methods); final Spinner paymentMethodSpinner = (Spinner) findViewById(R.id.payment_method_spinner); final RadioButton paid = (RadioButton) findViewById(R.id.paid); paid.setTypeface(MainOffence.Roboto_Regular); final RadioButton not_paid = (RadioButton) findViewById(R.id.not_paid); final TextView receipt_title = (TextView) findViewById(R.id.receipt_title); receiptEditText = (EditText) findViewById(R.id.receipt); receipt_title.setTypeface(MainOffence.Roboto_BoldCondensed); not_paid.setTypeface(MainOffence.Roboto_Regular); not_paid.setChecked(true); paymentMethodSpinner.setBackground(null); paid.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b == true) { paymentStatus = true; paymentMethodTitle.setVisibility(View.VISIBLE); paymentMethodSpinner.setVisibility(View.VISIBLE); paymentMethod = paymentMethodsArray[0]; paymentMethodSpinner.setSelection(0); receipt_title.setVisibility(View.VISIBLE); receiptEditText.setVisibility(View.VISIBLE); } } }); not_paid.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b == true) { paymentStatus = false; paymentMethodTitle.setVisibility(View.GONE); paymentMethodSpinner.setVisibility(View.GONE); receipt_title.setVisibility(View.GONE); receiptEditText.setVisibility(View.GONE); paymentMethod = ""; receiptEditText.setText(""); } } }); PaymentMethodSpinnerAdapter adapter = new PaymentMethodSpinnerAdapter( getSupportActionBar().getThemedContext(), R.layout.row_menu, paymentMethodsArray); paymentMethodSpinner.setAdapter(adapter); paymentMethodSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { paymentMethod = paymentMethodsArray[position]; if (position == 0) { receiptEditText.setVisibility(View.VISIBLE); receipt_title.setVisibility(View.VISIBLE); } else { receiptEditText.setVisibility(View.GONE); receipt_title.setVisibility(View.GONE); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); }
From source file:com.serenegiant.autoparrot.BaseAutoPilotFragment.java
private void initCamera(final View rootView) { mCameraExposureFormat = getString(R.string.trace_camera_exposure); mCameraSaturationFormat = getString(R.string.trace_camera_saturation); mCameraPanFormat = getString(R.string.trace_camera_pan); mCameraTiltFormat = getString(R.string.trace_camera_tilt); SeekBar sb;/*from w ww.j a v a 2s. c o m*/ // ? mCameraAutoWhiteBlance = getInt(mPref, KEY_CAMERA_WHITE_BLANCE, DEFAULT_CAMERA_WHITE_BLANCE); final Spinner spinner = (Spinner) rootView.findViewById(R.id.camera_white_blance_spinner); spinner.setAdapter(new WhiteBlanceAdapter(getActivity())); spinner.setSelection(mCameraAutoWhiteBlance + 1); spinner.setOnItemSelectedListener(mOnItemSelectedListener); // mCameraExposure = mPref.getFloat(KEY_CAMERA_EXPOSURE, DEFAULT_CAMERA_EXPOSURE); mCameraExposureLabel = (TextView) rootView.findViewById(R.id.camera_exposure_textview); sb = (SeekBar) rootView.findViewById(R.id.camera_exposure_seekbar); sb.setMax(3000); sb.setProgress(cameraExposureToProgress(mCameraExposure)); // [-1.5,+ 1.5] => [0, 3000] sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateCameraExposure(mCameraExposure); // mCameraSaturation = mPref.getFloat(KEY_CAMERA_SATURATION, DEFAULT_CAMERA_SATURATION); mCameraSaturationLabel = (TextView) rootView.findViewById(R.id.camera_saturation_textview); sb = (SeekBar) rootView.findViewById(R.id.camera_saturation_seekbar); sb.setMax(2000); sb.setProgress((int) (mCameraSaturation * 10.0f) + 1000); // [-100.0f, +100.0f] => [0, 2000] sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateCameraSaturation(mCameraSaturation); // mCameraPan = getInt(mPref, KEY_CAMERA_PAN, DEFAULT_CAMERA_PAN); mCameraPanLabel = (TextView) rootView.findViewById(R.id.camera_pan_textview); sb = (SeekBar) rootView.findViewById(R.id.camera_pan_seekbar); sb.setMax(40); sb.setProgress(cameraPanTiltToProgress(mCameraPan)); // [-100,+100] => [0, 40] sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateCameraPan(mCameraPan); // ? mCameraTilt = getInt(mPref, KEY_CAMERA_TILT, DEFAULT_CAMERA_TILT); mCameraTiltLabel = (TextView) rootView.findViewById(R.id.camera_tilt_textview); sb = (SeekBar) rootView.findViewById(R.id.camera_tilt_seekbar); sb.setMax(40); sb.setProgress(cameraPanTiltToProgress(mCameraTilt)); // [-100,+100] => [0, 40] sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateCameraTilt(mCameraTilt); }
From source file:hu.fnf.devel.atlas.Atlas.java
public void addCat(View view) { Spinner spinner = (Spinner) findViewById(R.id.taskSpinner); // In case of null add! if (spinner.getSelectedItem() == null) { Log.d("Atlas", "null selection"); return;/*from w w w . j a va 2s .c o m*/ } String selected = (String) spinner.getSelectedItem(); /* * add to list */ Category sel = categories.get(selected); Log.d("Atlas", "selected: " + selected); Log.d("Atlas", "id: " + sel.getId()); ListView cats = (ListView) findViewById(R.id.taskCats); CatAddAdapter catAddAdapter = (CatAddAdapter) cats.getAdapter(); if (catAddAdapter.getSum() >= (int) (catAddAdapter.getAmount()) + Integer.valueOf(sel.getAmount())) { AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(this); myAlertDialog.setTitle("--- Task ---"); myAlertDialog.setMessage("Nothing left to categorize"); myAlertDialog.setPositiveButton(getResources().getString(R.string.ok), AtlasData.ackClick); myAlertDialog.show(); return; } catAddAdapter.add(new Category(sel.getId(), sel.getName(), sel.getAmount(), sel.getDepth(), sel.getColorr(), sel.getColorg(), sel.getColorb())); cats.setAdapter(catAddAdapter); //remove from spinner ArrayList<String> array_spinner = new ArrayList<String>(); int spin_count = spinner.getAdapter().getCount(); Log.d("Atlas", "spinner count: " + spin_count); if (spin_count == 1) { // no more category in spinner (ASANA: mi legyen ha elfogy a spinner) Log.d("Atlas", "no more category in spinner"); ImageView add = (ImageView) findViewById(R.id.taskAdd); add.setVisibility(View.INVISIBLE); add.setEnabled(false); spinner.setVisibility(View.INVISIBLE); spinner.setEnabled(false); } for (int i = 0; i < spin_count; i++) { String s = (String) spinner.getAdapter().getItem(i); if (!s.equalsIgnoreCase(selected)) { array_spinner.add(s); } } ArrayAdapter<String> arrayadapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.custom_simple_spinner, array_spinner); spinner.setAdapter(arrayadapter); }
From source file:cl.gisred.android.CatastroActivity.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);/*ww w . j ava2 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 != 3) { 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 == 3) { 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 { 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 // 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: iBusqScale = 5000; String[] sBuscar = { eStreet.getText().toString(), eNumber.getText().toString() }; String[] sFields = { "nombre_calle", "numero" }; callQuery(sBuscar, sFields, LyDIRECCIONES.getUrl().concat("/0")); break; } } } }); dialogBusqueda.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); dialogBusqueda.show(); }
From source file:cl.gisred.android.MedidorActivity.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. jav a2 s . c o m v.setMinimumWidth(widthScale); formCrear.setTitle(sNombre); formCrear.setContentView(v); idResLayoutSelect = idRes; Spinner spUserCosenza = (Spinner) v.findViewById(R.id.spinnerUser); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayUserCosenza); spUserCosenza.setAdapter(adapter); 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); Log.w("[LectorActivity]", "HIDE FORM POSTE and Zoom"); 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:cl.gisred.android.LectorActivity.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 ava2 s .com*/ v.setMinimumWidth(widthScale); formCrear.setTitle(sNombre); formCrear.setContentView(v); idResLayoutSelect = idRes; if (idRes == R.layout.form_lectores) { Spinner spUserCosenza = (Spinner) v.findViewById(R.id.spinnerUser); adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayUserCosenza); spUserCosenza.setAdapter(adapter); } 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:cl.gisred.android.RegEquipoActivity.java
public void setActionsFormAgr(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 a2 s . c o m*/ v.setMinimumWidth(widthScale); formCrear.setTitle(sNombre); formCrear.setContentView(v); idResLayoutSelect = idRes; 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 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)); } }); ImageButton btnClose = (ImageButton) v.findViewById(R.id.btnCancelar); btnClose.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { cerrarFormLimit(false, v); } }); ImageButton btnOk = (ImageButton) v.findViewById(R.id.btnConfirmar); btnOk.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { cerrarFormLimit(true, v); } }); formCrear.show(); dialogCur = formCrear; }
From source file:com.example.android.lightcontrol.MainActivity.java
private void light_configure() { LayoutInflater inflater = LayoutInflater.from(this); final View v = inflater.inflate(R.layout.light_configure, null); final AlertDialog.Builder dialog = new AlertDialog.Builder(this); helper = new DBHelper(getApplicationContext()); cursor = helper.select(TABLE_NAME_DALISLAVEADDRESS); final EditText change_light_name = (EditText) v.findViewById(R.id.editText3); Button change_name = (Button) v.findViewById(R.id.button3); final Spinner light_list = (Spinner) v.findViewById(R.id.light_list); final SimpleCursorAdapter adapter = new SimpleCursorAdapter(MainActivity.this, R.layout.message, cursor, new String[] { "_dali_name" }, new int[] { R.id.message }); light_list.setAdapter(adapter); light_list.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override//from w w w . jav a 2s. co m public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { cursor.moveToPosition(i); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); change_name.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { helper.update(cursor.getInt(0), TABLE_NAME_DALISLAVEADDRESS, FEILD_NAME_DALI, String.valueOf(change_light_name.getText())); helper.close(); cursor.close(); helper = new DBHelper(getApplicationContext()); cursor = helper.select(TABLE_NAME_DALISLAVEADDRESS); adapter.notifyDataSetChanged(); final Spinner light_list = (Spinner) v.findViewById(R.id.light_list); final SimpleCursorAdapter adapter = new SimpleCursorAdapter(MainActivity.this, R.layout.message, cursor, new String[] { "_dali_name" }, new int[] { R.id.message }); light_list.setAdapter(adapter); } }); 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) { updatespinner(); helper.close(); cursor.close(); } }); dialog.show(); }
From source file:com.example.android.lightcontrol.MainActivity.java
public void updatespinner() { //DB?UserGroupSpinner? helper = new DBHelper(getApplicationContext()); cursor = helper.select(TABLE_NAME_DALISLAVEADDRESS); if (cursor.getCount() > 0) { Spinner spinner = (Spinner) findViewById(R.id.mySpinner); cursor.moveToFirst();/* w w w . j a v a 2 s . c om*/ SimpleCursorAdapter adapter = new SimpleCursorAdapter(MainActivity.this, R.layout.message, cursor, new String[] { "_dali_name" }, new int[] { R.id.message }); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { helper = new DBHelper(getApplicationContext()); cursor = helper.select(TABLE_NAME_DALISLAVEADDRESS); cursor.moveToPosition(i); if (cursor.getString(1) != null) { GlobalVariable.OnSpinnerItemSelected = cursor.getString(1); //if (cursor.getString(2)!=null){ //GlobalVariable.OnSpinnerItemSelectedOfShort = cursor.getString(2);} // if (D) // Log.e(TAG, "GlobalVariable.OnSpinnerItemSelected = : " + GlobalVariable.OnSpinnerItemSelected); } } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); } }
From source file:cl.gisred.android.LectorActivity.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 ww w .j a va 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 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(); }