Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case DIALOG_VIN_ENTRY:
- {
- //do things
- Dialog dialog = new Dialog(this);
- builder = new AlertDialog.Builder(this);
- builder.setTitle("Vehicle Entry");
- final View dialogLayout = inflater.inflate(R.layout.dialog_vin_entry, null);
- final EditText vin = (EditText)dialogLayout.findViewById(R.id.vin_in);
- final Spinner make = (Spinner)dialogLayout.findViewById(R.id.make_spn);
- final Spinner model = (Spinner)dialogLayout.findViewById(R.id.model_spn);
- final Spinner year = (Spinner)dialogLayout.findViewById(R.id.year_spn);
- final Spinner title = (Spinner)dialogLayout.findViewById(R.id.title_spn);
- final Spinner color = (Spinner)dialogLayout.findViewById(R.id.color_spn);
- //check for a VIN scan string and place appropriately
- if(b!=null && b.containsKey("scannerRead")) {
- vin.setText(b.getString("scannerRead"));
- }
- // Create a BroadcastReceiver for ACTION_FOUND, ACTION_STATE_CHANGED, ACTION_DISCOVERY_FINISHED
- final BroadcastReceiver dialogReceiver = new BroadcastReceiver() {
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (ScannerService.ACTION_READ_SCANNER.equals(action)) {
- String tmp = intent.getStringExtra("scannerRead");
- vin.setText(tmp);
- }
- }
- };
- //make will have to be a CursorAdapter implementation
- //model will have to be a CursorAdapter implementation
- //attach year to the dynamic array we created with years
- ArrayAdapter yearAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, mYearList);
- yearAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- year.setAdapter(yearAdapter);
- //attach title to the static title array.
- ArrayAdapter titleAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.title_array));
- titleAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- title.setAdapter(titleAdapter);
- //attach color to the static color array
- ArrayAdapter colorAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.color_array));
- colorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- color.setAdapter(colorAdapter);
- builder = new AlertDialog.Builder(this);
- builder.setView(dialogLayout);
- builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- String vinString = vin.getText().toString();
- String makeString = (String)make.getSelectedItem();
- String modelString = (String)model.getSelectedItem();
- String yearString = (String)year.getSelectedItem();
- String titleString = (String)title.getSelectedItem();
- String colorString = (String)color.getSelectedItem();
- dialog.getContext().unregisterReceiver(dialogReceiver);
- dialog.dismiss();
- }
- });
- builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.getContext().unregisterReceiver(dialogReceiver);
- dialog.dismiss();
- }
- });
- dialog = builder.create();
- IntentFilter filter = new IntentFilter();
- filter.addAction(ScannerService.ACTION_READ_SCANNER);
- dialog.getContext().registerReceiver(dialogReceiver, filter);
- return dialog;
- }
Advertisement
Add Comment
Please, Sign In to add comment