Пример #1
0
        @Override
        public void onServiceConnected(ComponentName className, IBinder serviceBinder) {
          Log.d("MainActivity", "service connected");

          // bound with Service. get Service instance
          MediaPlayerService.MediaPlayerBinder binder =
              (MediaPlayerService.MediaPlayerBinder) serviceBinder;
          mService = binder.getService();

          // send this instance to the service, so it can make callbacks on
          // this instance as a client
          mService.setClient(ListenFragment.this);
          mBound = true;

          // Set play/pause button to reflect state of the service's contained
          // player
          final ToggleButton playPauseButton =
              (ToggleButton) rootView.findViewById(R.id.playPauseButton);
          playPauseButton.setChecked(mService.getMediaPlayer().isPlaying());

          // Set station Picker to show currently set stream station
          Spinner stationPicker = (Spinner) rootView.findViewById(R.id.stationPicker);
          if (mService.getMediaPlayer() != null
              && mService.getMediaPlayer().getStreamStation() != null) {
            for (int i = 0; i < RadioList.ALl_STATIONS.length; i++) {
              if (mService.getMediaPlayer().getStreamStation().equals(RadioList.ALl_STATIONS[i])) {
                stationPicker.setSelection(i);
                mSelectedStream = (StreamStation) stationPicker.getItemAtPosition(i);
              }
            }
          }
        }
Пример #2
0
 public static void setSpinnerOptionValue(Spinner spinner, Object value) {
   for (int i = 0, count = spinner.getCount(); i < count; i++) {
     SpinnerOption so = (SpinnerOption) spinner.getItemAtPosition(i);
     if (so.value.equals(value)) {
       spinner.setSelection(i, true);
       return;
     }
   }
 }
Пример #3
0
 /**
  * 设置选中某一些 下拉框
  *
  * @author [email protected] 2013-10-12 下午3:47:34
  * @param spinner
  * @param selection
  * @return void
  */
 public static void setSelection(Spinner spinner, String selection) {
   final int count = spinner.getCount();
   for (int i = 0; i < count; i++) {
     String item = spinner.getItemAtPosition(i).toString();
     if (item.equalsIgnoreCase(selection)) {
       spinner.setSelection(i);
     }
   }
 }
 void SetupSpinner(final int sid, final Spinner spinner) {
   for (int i = 0; i < spinner.getCount(); i++) {
     Cursor value = (Cursor) spinner.getItemAtPosition(i);
     int id = value.getInt(value.getColumnIndex(BaseColumns._ID));
     if (id == sid) {
       spinner.setSelection(i);
       break;
     }
   }
 }
Пример #5
0
 @Override
 public void onItemSelected(AdapterView<?> parent, View view, final int position, long id) {
   final ArrayAdapter<String> adapter = ((ArrayAdapter<String>) mUnits.getAdapter());
   if (mEvents != null
       && mCurrentUnit != null
       && !adapter.getItem(position).equals(mCurrentUnit)) {
     mEvents.onUnitChange(mUnits.getItemAtPosition(position).toString());
     mCurrentUnit = adapter.getItem(position);
   }
 }
  private int getIndex(Spinner spinner, String string) {
    int index = 0;

    for (int i = 0; i < spinner.getCount(); i++) {
      if (spinner.getItemAtPosition(i).equals(string)) {
        index = i;
      }
    }
    return index;
  }
Пример #7
0
  @Override
  protected void onInflate(Bundle savedInstanceState) {
    setContentView(R.layout.contact_add);

    ListView listView = getListView();
    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.contact_add_header, listView, false);
    listView.addHeaderView(view, null, false);

    accountView = (Spinner) view.findViewById(R.id.contact_account);
    accountView.setAdapter(new AccountChooseAdapter(this));
    accountView.setOnItemSelectedListener(this);
    userView = (EditText) view.findViewById(R.id.contact_user);
    nameView = (EditText) view.findViewById(R.id.contact_name);
    ((Button) view.findViewById(R.id.ok)).setOnClickListener(this);

    String name;
    Intent intent = getIntent();
    if (savedInstanceState != null) {
      account = savedInstanceState.getString(SAVED_ACCOUNT);
      user = savedInstanceState.getString(SAVED_USER);
      name = savedInstanceState.getString(SAVED_NAME);
    } else {
      account = getAccount(intent);
      user = getUser(intent);
      if (account == null || user == null) name = null;
      else {
        name = RosterManager.getInstance().getName(account, user);
        if (user.equals(name)) name = null;
      }
    }
    if (account == null) {
      Collection<String> accounts = AccountManager.getInstance().getAccounts();
      if (accounts.size() == 1) account = accounts.iterator().next();
    }
    if (account != null) {
      for (int position = 0; position < accountView.getCount(); position++)
        if (account.equals(accountView.getItemAtPosition(position))) {
          accountView.setSelection(position);
          break;
        }
    }
    if (user != null) userView.setText(user);
    if (name != null) nameView.setText(name);
    if (ACTION_SUBSCRIPTION_REQUEST.equals(intent.getAction())) {
      subscriptionRequest = PresenceManager.getInstance().getSubscriptionRequest(account, user);
      if (subscriptionRequest == null) {
        Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND);
        finish();
        return;
      }
    } else {
      subscriptionRequest = null;
    }
  }
  private int getIndex(Spinner spinner, Integer myString) {

    int index = 0;

    for (int i = 0; i < spinner.getCount(); i++) {
      if (spinner.getItemAtPosition(i) == myString) {
        index = i;
      }
    }
    return index;
  }
 private static void setSpinnerPosition(Spinner spinner, Object itemToSelect) {
   final SpinnerAdapter adapter = spinner.getAdapter();
   final int count = adapter.getCount();
   for (int i = 0; i < count; i++) {
     final Object item = spinner.getItemAtPosition(i);
     if (item.equals(itemToSelect)) {
       spinner.setSelection(i);
       return;
     }
   }
 }
Пример #10
0
  // private method of your class
  private int getIndex(Spinner spinner, String myString) {
    int index = 0;

    for (int i = 0; i < spinner.getCount(); i++) {
      if (spinner.getItemAtPosition(i).toString().equalsIgnoreCase(myString)) {
        index = i;
        break;
      }
    }
    return index;
  }
Пример #11
0
  private void getIndex(Spinner spinner, String myString) {

    int index = 0;

    for (int i = 0; i < spinner.getCount(); i++) {
      if (spinner.getItemAtPosition(i).equals(myString)) {
        index = i;
      }
    }
    spinner.setSelection(index);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_cadastro);

    TelephonyManager tm = (TelephonyManager) getSystemService(this.TELEPHONY_SERVICE);
    // get IMEI
    imei = tm.getDeviceId();

    disp = daoDisp.getDispositivo();

    edNome = (EditText) findViewById(R.id.edNome);
    tempo = (Spinner) findViewById(R.id.tempo);
    btCadastra = (Button) findViewById(R.id.btCadastra);

    edNome.setText(imei);

    // Definição do evento do clique do botao cadastrar
    btCadastra.setOnClickListener(
        new OnClickListener() {

          public void onClick(View view) {

            // Salva as informações de cadastro
            disp.setId(1);
            disp.setNmDispositivo(imei);
            disp.setIntervalo((Integer) tempo.getSelectedItem());

            daoDisp.atualizar(disp);

            // Exibe uma mensagem de sucesso
            Toast.makeText(
                    getApplicationContext(), "Dados atualizados com sucesso!", Toast.LENGTH_LONG)
                .show();

            finish();
          }
        });

    Spinner combo = (Spinner) findViewById(R.id.tempo);
    ArrayAdapter adp =
        new ArrayAdapter<Integer>(this, android.R.layout.simple_spinner_item, MINUTOS);
    adp.setDropDownViewResource(android.R.layout.simple_spinner_item);
    combo.setAdapter(adp);

    if (disp.getIntervalo() != null)
      for (int i = 0; i < combo.getCount(); i++) {
        int f = (Integer) combo.getItemAtPosition(i);
        if (f == disp.getIntervalo()) {
          combo.setSelection(i);
        }
      }
  }
Пример #13
0
  private int getIndex(Spinner spinnerGlobalService, String strService) {

    int index = 0;

    for (int i = 0; i < spinnerGlobalService.getCount(); i++) {
      if (spinnerGlobalService.getItemAtPosition(i).toString().equalsIgnoreCase(strService)) {
        index = i;
        break;
      }
    }

    return index;
  }
Пример #14
0
  /**
   * Initializes the Methods drop down menu in sliding menu
   *
   * @param s Spinner to contain all Methods
   */
  private void initializeMethods(Spinner s) {
    List<String> list = new ArrayList<String>(TransformationBuilder.getHomographyMethodNames());
    ArrayAdapter<String> dataAdapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, list);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    s.setAdapter(dataAdapter);

    // Set default value
    String method = tranBuilder.getCurrentHomographyMethod();
    int num = s.getCount();
    for (int i = 0; i < num; ++i) {
      if (s.getItemAtPosition(i).equals(method)) {
        s.setSelection(i);
        break;
      }
    }

    s.setOnItemSelectedListener(this);
  }
Пример #15
0
  /** set the right alarm interval from the spinner */
  public void setIntervalFromSpinner() {

    Object selectedInterval =
        repeatSpinner.getItemAtPosition(repeatSpinner.getSelectedItemPosition());

    if (selectedInterval.equals("No Repeating")) {

    } else if (selectedInterval.equals("Daily")) {
      setRepeatAlarmInterval(AlarmManager.INTERVAL_DAY);
    } else if (selectedInterval.equals("Every Hour")) {
      setRepeatAlarmInterval(AlarmManager.INTERVAL_HOUR);
    } else if (selectedInterval.equals("Every 30 Minutes")) {
      setRepeatAlarmInterval(AlarmManager.INTERVAL_HALF_HOUR);
    } else if (selectedInterval.equals("Every 15 Minutes")) {
      setRepeatAlarmInterval(AlarmManager.INTERVAL_FIFTEEN_MINUTES);
    }

    // set the index of the child of the spinner, for edit mode
    setIntervalIndexFromSpinner(repeatSpinner.getSelectedItemPosition());
    Log.i(getClass().getSimpleName(), "interval: " + getRepeatAlarmInterval());
    Log.i(getClass().getSimpleName(), "Interval index selected: " + getIntervalIndexFromSpinner());
  }
Пример #16
0
  public void showDataInMyContact(View myContactView) {

    if (myContactView == null) return;

    // lade Daten in UI
    try {

      SQLiteConnection db_conn = new SQLiteConnection(this);

      String[] user_res = db_conn.getUser();

      if (user_res != null) {
        TextView tv_name = (TextView) myContactView.findViewById(R.id.mycontact_tv_name);
        TextView tv_frontname = (TextView) myContactView.findViewById(R.id.mycontact_tv_frontname);
        ImageView iv_pic = (ImageView) myContactView.findViewById(R.id.mycontact_iv_picture);

        tv_name.setText(user_res[2]);
        tv_frontname.setText(user_res[3]);

        if (!(user_res[6] == null || user_res[6].equals("") || user_res[6].equals("null"))) {

          byte[] imageAsBytes = Base64.decode(user_res[6].getBytes(), Base64.DEFAULT);
          Bitmap bmPic = BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length);

          int x = Functions.dpsToPx(this, 64);
          bmPic = Functions.scaleCenterCrop(bmPic, x, x);

          iv_pic.setImageBitmap(bmPic);
        }
      }

      LinearLayout ll_telephone =
          (LinearLayout) myContactView.findViewById(R.id.mycontact_ll_data_telephone);
      LinearLayout ll_email =
          (LinearLayout) myContactView.findViewById(R.id.mycontact_ll_data_email);
      LinearLayout ll_other =
          (LinearLayout) myContactView.findViewById(R.id.mycontact_ll_data_other);

      // jetzigen Inhalt l�schen
      ll_telephone.removeAllViews();
      ll_email.removeAllViews();

      ll_other.removeAllViews();

      Cursor mycontact_data =
          db_conn.query(
              "SELECT entrynames_id,value FROM "
                  + SQLiteConnection.TABLE_USER_DATA
                  + " ORDER BY entrynames_id");

      for (int i = 0; i < mycontact_data.getCount(); i++) {

        mycontact_data.moveToPosition(i);

        String name = array_en_name[Functions.indexOf(array_en_id, mycontact_data.getInt(0))];
        String type = array_en_type[Functions.indexOf(array_en_id, mycontact_data.getInt(0))];

        String value = mycontact_data.getString(1);
        String[] splitedValue = value.split("\\|");

        createNewContactObject(type, myContactView);
        LinearLayout container;

        if (type.equals("number")) {
          container = ll_telephone;
        } else if (type.equals("email")) {
          container = ll_email;
        } else {
          container = ll_other;
        }

        LinearLayout child = (LinearLayout) container.getChildAt(container.getChildCount() - 1);

        Spinner spinner = (Spinner) child.getChildAt(1);

        String items[] = new String[spinner.getAdapter().getCount()];
        for (int a = 0; a < spinner.getAdapter().getCount(); a++) {
          items[a] = ((String) spinner.getItemAtPosition(a)).toLowerCase(new Locale("en"));
        }

        if (splitedValue.length >= 2) {
          String[] newItems = new String[items.length + 1];
          System.arraycopy(items, 0, newItems, 0, items.length);
          newItems[newItems.length - 1] = splitedValue[0];

          MySpinnerArrayAdapter adapter =
              new MySpinnerArrayAdapter(
                  this, newItems, ((MySpinnerArrayAdapter) spinner.getAdapter()).getLargeScreen());
          spinner.setAdapter(adapter);
          spinner.setSelection(newItems.length - 1);
          ((EditText) child.getChildAt(0)).setText(splitedValue[1]);
        } else {
          spinner.setSelection(Functions.indexOf(items, name.toLowerCase(new Locale("en"))));
          ((EditText) child.getChildAt(0)).setText(value);
        }
      }

      mycontact_data.close();

      db_conn.close();

      myContactIsLoaded = true;
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    setContentView(R.layout.data_point_properties);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    Bundle extras = getIntent().getExtras();
    String tableName = extras.getString(SpatialiteLibraryConstants.PREFS_KEY_TEXT);
    try {
      spatialTable = SpatialDatabasesManager.getInstance().getVectorTableByName(tableName);
    } catch (Exception e) {
      GPLog.error(this, null, e);
    }

    shapesSpinner = (Spinner) findViewById(R.id.shape_spinner);
    String shape = spatialTable.getStyle().shape;
    int count = shapesSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (shapesSpinner.getItemAtPosition(i).equals(shape)) {
        shapesSpinner.setSelection(i);
        break;
      }
    }
    String size = String.valueOf((int) spatialTable.getStyle().size);
    sizeSpinner = (Spinner) findViewById(R.id.size_spinner);
    count = sizeSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (sizeSpinner.getItemAtPosition(i).equals(size)) {
        sizeSpinner.setSelection(i);
        break;
      }
    }

    colorSpinner = (Spinner) findViewById(R.id.color_spinner);
    String strokecolor = spatialTable.getStyle().strokecolor;
    count = colorSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (colorSpinner.getItemAtPosition(i).equals(strokecolor)) {
        colorSpinner.setSelection(i);
        break;
      }
    }
    String width = String.valueOf((int) spatialTable.getStyle().width);
    widthSpinner = (Spinner) findViewById(R.id.width_spinner);
    count = widthSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (widthSpinner.getItemAtPosition(i).equals(width)) {
        widthSpinner.setSelection(i);
        break;
      }
    }
    String alpha = String.valueOf((int) (spatialTable.getStyle().strokealpha * 100f));
    alphaSpinner = (Spinner) findViewById(R.id.alpha_spinner);
    count = alphaSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (alphaSpinner.getItemAtPosition(i).equals(alpha)) {
        alphaSpinner.setSelection(i);
        break;
      }
    }

    fillColorSpinner = (Spinner) findViewById(R.id.fill_color_spinner);
    String fillcolor = spatialTable.getStyle().fillcolor;
    count = fillColorSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (fillColorSpinner.getItemAtPosition(i).equals(fillcolor)) {
        fillColorSpinner.setSelection(i);
        break;
      }
    }

    String fillAlpha = String.valueOf((int) (spatialTable.getStyle().fillalpha * 100f));
    fillAlphaSpinner = (Spinner) findViewById(R.id.fill_alpha_spinner);
    count = fillAlphaSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (fillAlphaSpinner.getItemAtPosition(i).equals(fillAlpha)) {
        fillAlphaSpinner.setSelection(i);
        break;
      }
    }

    int minZoom = spatialTable.getMinZoom();
    int tableMinZoom = 0; // spatialTable.getMinZoom();
    int tableMaxZoom = 22; // spatialTable.getMaxZoom();
    ArrayList<String> minMaxSequence = new ArrayList<String>();
    for (int i = tableMinZoom; i <= tableMaxZoom; i++) {
      minMaxSequence.add(String.valueOf(i));
    }
    minZoomSpinner = (Spinner) findViewById(R.id.minzoom_spinner);
    ArrayAdapter<String> queryAdapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, minMaxSequence);
    queryAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    minZoomSpinner.setAdapter(queryAdapter);
    count = minZoomSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (minZoomSpinner.getItemAtPosition(i).equals(String.valueOf(minZoom))) {
        minZoomSpinner.setSelection(i);
        break;
      }
    }

    int maxZoom = spatialTable.getMaxZoom();
    maxZoomSpinner = (Spinner) findViewById(R.id.maxzoom_spinner);
    queryAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    maxZoomSpinner.setAdapter(queryAdapter);
    count = maxZoomSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (maxZoomSpinner.getItemAtPosition(i).equals(String.valueOf(maxZoom))) {
        maxZoomSpinner.setSelection(i);
        break;
      }
    }

    String dashPattern = spatialTable.getStyle().dashPattern;
    dashPatternText = (EditText) findViewById(R.id.dashpattern_text);
    dashPatternText.setText(dashPattern);
  }
  public void onAddEvent(View view) {

    // getting Et as a string
    String event_nameET = String.valueOf(event_name.getText());
    String locationET = String.valueOf(location.getText());
    String Start_DateET = String.valueOf(Start_Date.getText());
    String Start_TimeET = String.valueOf(Start_Time.getText());
    String End_DateET = String.valueOf(End_Date.getText());
    String End_TimeET = String.valueOf(End_Time.getText());
    String CategoryName = spinnerCategory.getSelectedItem().toString();
    String TypeName = spinnerType.getSelectedItem().toString();
    String descriptionET = String.valueOf(description.getText());

    // get the latitude and longitude of location
    getLatitudeLongitudeOfLocation(locationET);

    // Read ObjectId from file
    readObjectIdFromFile();

    System.out.println("LatitudeOfLocation........" + LatitudeOfLocation + "...................");
    System.out.println("LongitudeOfLocation........" + LongitudeOfLocation + "...................");

    // check the validatiy of fields
    if (event_nameET.trim().length() == 0) {
      new AlertDialog.Builder(this)
          .setTitle("Warning")
          .setMessage("Please fill the event name!")
          .setNeutralButton("Close", null)
          .show();
    } else if (locationET.trim().length() == 0) {
      new AlertDialog.Builder(this)
          .setTitle("Warning")
          .setMessage("Please fill the location!")
          .setNeutralButton("Close", null)
          .show();
    } else if (Start_DateET.trim().length() == 0) {
      new AlertDialog.Builder(this)
          .setTitle("Warning")
          .setMessage("Please fill the start date!")
          .setNeutralButton("Close", null)
          .show();
    } else if (Start_TimeET.trim().length() == 0) {
      new AlertDialog.Builder(this)
          .setTitle("Warning")
          .setMessage("Please fill the start time!")
          .setNeutralButton("Close", null)
          .show();
    } else if (End_DateET.trim().length() == 0) {
      new AlertDialog.Builder(this)
          .setTitle("Warning")
          .setMessage("Please fill the end date!")
          .setNeutralButton("Close", null)
          .show();
    } else if (End_TimeET.trim().length() == 0) {
      new AlertDialog.Builder(this)
          .setTitle("Warning")
          .setMessage("Please fill the end time!")
          .setNeutralButton("Close", null)
          .show();
    } else if (CategoryName.equals(spinnerCategory.getItemAtPosition(0))) {
      new AlertDialog.Builder(this)
          .setTitle("Warning")
          .setMessage("Please select a suitable category name!")
          .setNeutralButton("Close", null)
          .show();
    } else if (TypeName.equals(spinnerType.getItemAtPosition(0))) {
      new AlertDialog.Builder(this)
          .setTitle("Warning")
          .setMessage("Please select a suitable type name!")
          .setNeutralButton("Close", null)
          .show();
    } else if (descriptionET.trim().length() == 0) {
      new AlertDialog.Builder(this)
          .setTitle("Warning")
          .setMessage("Please fill the description!")
          .setNeutralButton("Close", null)
          .show();
    } else {

      // save to the Parse
      ParseObject testAccount = new ParseObject("TestEvent");
      testAccount.put("Event_Name", event_nameET);
      testAccount.put("Location", locationET);
      testAccount.put("Latitude", LatitudeOfLocation);
      testAccount.put("Longitude", LongitudeOfLocation);
      testAccount.put("Start_Date", Start_DateET);
      testAccount.put("Start_Time", Start_TimeET);
      testAccount.put("End_Date", End_DateET);
      testAccount.put("End_Time", End_TimeET);
      testAccount.put("Category_Name", CategoryName);
      testAccount.put("Type_Name", TypeName);
      testAccount.put("Description", descriptionET);
      testAccount.put("Event_Creater", ObjectIdOfUser);
      testAccount.saveInBackground();

      // Show added message to user
      new AlertDialog.Builder(this)
          .setTitle("Congratulations")
          .setMessage("Your event is successfully added !")
          .setNeutralButton("Continue", null)
          .show();

      // convert them to default value
      event_name.setText("");
      location.setText("");
      Start_Date.setText("");
      Start_Time.setText("");
      End_Date.setText("");
      End_Time.setText("");
      spinnerCategory.setSelection(0);
      spinnerType.setSelection(0);
      description.setText("");

      // Direct user to the my events tab
      MainActivity parentActivity;
      parentActivity = (MainActivity) this.getParent();
      parentActivity.switchTab(4);

      /*
      Intent intent = new Intent(this,MainActivity.class);
      startActivity(intent);
      */
    }
  }
Пример #19
0
 @Override
 public void onItemSelected(AdapterView<?> pWRent, View view, int position, long id) {
   s1 = s.getItemAtPosition(position).toString();
 }
  private void selectTestGroup(int pos) {
    TestGroup tg = (TestGroup) mTestGroupSpinner.getItemAtPosition(pos);
    List<TestCase> testCases = tg.getTestCases();

    fillTestList(testCases);
  }
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    setContentView(R.layout.data_point_properties);
    style = getStyle();
    setBaseStyleProperties(style);

    // Set default color for fill and stroke color by attribute of style.
    colorSelStroke = Color.parseColor(style.strokecolor);
    colorSelFill = Color.parseColor(style.fillcolor);

    shapesSpinner = (Spinner) findViewById(R.id.shape_spinner);
    String shape = style.shape;
    int count = shapesSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (shapesSpinner.getItemAtPosition(i).equals(shape)) {
        shapesSpinner.setSelection(i);
        break;
      }
    }
    String size = String.valueOf((int) style.size);
    sizeSpinner = (Spinner) findViewById(R.id.size_spinner);
    count = sizeSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (sizeSpinner.getItemAtPosition(i).equals(size)) {
        sizeSpinner.setSelection(i);
        break;
      }
    }

    colorStroke = (TextView) findViewById(R.id.textView1);
    colorStroke.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // Show a dialog with color picker
            colorPicker(colorSelStroke, who.Stroke);
          }
        });

    String width = String.valueOf((int) style.width);
    widthSpinner = (Spinner) findViewById(R.id.width_spinner);
    count = widthSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (widthSpinner.getItemAtPosition(i).equals(width)) {
        widthSpinner.setSelection(i);
        break;
      }
    }
    String alpha = String.valueOf((int) (style.strokealpha * 100f));
    alphaSpinner = (Spinner) findViewById(R.id.alpha_spinner);
    count = alphaSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (alphaSpinner.getItemAtPosition(i).equals(alpha)) {
        alphaSpinner.setSelection(i);
        break;
      }
    }

    colorFill = (TextView) findViewById(R.id.textView4);
    colorFill.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // Show a dialog with color picker
            colorPicker(colorSelFill, who.Fill);
          }
        });

    String fillAlpha = String.valueOf((int) (style.fillalpha * 100f));
    fillAlphaSpinner = (Spinner) findViewById(R.id.fill_alpha_spinner);
    count = fillAlphaSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (fillAlphaSpinner.getItemAtPosition(i).equals(fillAlpha)) {
        fillAlphaSpinner.setSelection(i);
        break;
      }
    }

    boolean dashed = style.dashed;
    array = this.getResources().getStringArray(R.array.array_dashes);

    dashSpinner = (Spinner) findViewById(R.id.dash_spinner);
    if (dashSpinner.getItemAtPosition(0).equals(array[0]) && !dashed) dashSpinner.setSelection(0);
    else dashSpinner.setSelection(1);
  }