예제 #1
1
  public static final void initIncome(Activity activity, final Spinner spinner) {
    final ArrayAdapter arrayAdapter_center =
        new ArrayAdapter(
            activity, LAYOUT_CENTER, activity.getResources().getStringArray(R.array.income));
    final ArrayAdapter arrayAdapter_left =
        new ArrayAdapter(
            activity, LAYOUT_LEFT, activity.getResources().getStringArray(R.array.income));
    arrayAdapter_center.setDropDownViewResource(DROP_DOWN_LAYOUT);
    arrayAdapter_left.setDropDownViewResource(DROP_DOWN_LAYOUT);
    spinner.setAdapter(arrayAdapter_center);
    spinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

            if (position == 0) {
              spinner.setAdapter(arrayAdapter_center);
            } else {
              spinner.setAdapter(arrayAdapter_left);
              spinner.setSelection(position);
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });
  }
예제 #2
1
  // Adds a reminder to the displayed list of reminders.
  // Returns true if successfully added reminder, false if no reminders can
  // be added.
  static boolean addReminder(
      Activity activity,
      View.OnClickListener listener,
      ArrayList<LinearLayout> items,
      ArrayList<Integer> values,
      ArrayList<String> labels,
      int minutes) {

    if (items.size() >= MAX_REMINDERS) {
      return false;
    }

    LayoutInflater inflater = activity.getLayoutInflater();
    LinearLayout parent = (LinearLayout) activity.findViewById(R.id.reminder_items_container);
    LinearLayout reminderItem = (LinearLayout) inflater.inflate(R.layout.edit_reminder_item, null);
    parent.addView(reminderItem);

    Spinner spinner = (Spinner) reminderItem.findViewById(R.id.reminder_value);
    Resources res = activity.getResources();
    spinner.setPrompt(res.getString(R.string.reminders_title));
    int resource = android.R.layout.simple_spinner_item;
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(activity, resource, labels);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);

    ImageButton reminderRemoveButton;
    reminderRemoveButton = (ImageButton) reminderItem.findViewById(R.id.reminder_remove);
    reminderRemoveButton.setOnClickListener(listener);

    int index = findMinutesInReminderList(values, minutes);
    spinner.setSelection(index);
    items.add(reminderItem);

    return true;
  }
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {

    CustomDialogBuilder builder = new CustomDialogBuilder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.fragment_search_adv, null);

    Spinner spinner = (Spinner) view.findViewById(R.id.sa_spinner);
    ArrayAdapter<CharSequence> adapter =
        ArrayAdapter.createFromResource(
            getActivity(), R.array.sa_search_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);

    builder
        .setCustomView(view)
        .setTitle(getResources().getString(R.string.sa_title))
        .setIcon(R.drawable.action_search)
        .setNeutralButton(
            getResources().getString(R.string.sa_search_btn),
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialogInterface, int i) {}
            });

    return builder.create();
  }
  public void setSelectedInfo(String provinceId, String cityId) {
    if (this.dtoList == null) return;

    try {
      for (int i = 0; i < this.dtoList.size(); i++) {
        if (this.dtoList.get(i).getId() == Integer.parseInt(provinceId)) {
          provinceSpinner.setSelection(i);
          provinceTextView.setText(this.dtoList.get(i).getName());

          provinceSelectedIndex = i;

          List<TreeNodeAppDto> childList = this.dtoList.get(i).getChilds();
          for (int j = 0; j < childList.size(); j++) {
            if (childList.get(j).getId() == Integer.parseInt(cityId)) {
              citySelectedIndex = j;

              citySpinner.setSelection(j);
              cityTextView.setText(childList.get(j).getName());

              return;
            }
          }
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #5
0
  private void initCarpoolLayout() {
    mSpinnerRouteLayout.setVisibility(View.VISIBLE);
    mSpinnerRoute.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            ((CarpoolingInfo) host).setRoute((String) parent.getItemAtPosition(position));
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });

    mSpinnerTemporaryLayout.setVisibility(View.VISIBLE);
    mSpinnerTemporaryCount.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            host.setTemporaryCount((String) parent.getItemAtPosition(position));
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });
  }
  public void updateSettings() {
    sp_sellto_system.setOnItemSelectedListener(null);
    sp_buyfrom_system.setOnItemSelectedListener(null);

    Task.Market req = EveDatabase.getDefaultRequiredPrice();
    Task.Market prod = EveDatabase.GetDefaultProducedPrice();

    if (req.order == Task.Market.Order.BUY) {
      rg_buyfrom_source.check(R.id.rb_buyfrom_buy);
    } else {
      rg_buyfrom_source.check(R.id.rb_buyfrom_sell);
    }
    if (prod.order == Task.Market.Order.BUY) {
      rg_sellto_source.check(R.id.rb_sellto_buy);
    } else {
      rg_sellto_source.check(R.id.rb_sellto_sell);
    }
    updateSystem(sp_sellto_system, prod.system);
    updateSystem(sp_buyfrom_system, req.system);

    sp_sellto_system.setOnItemSelectedListener(new SystemSelectedListener(false));
    sp_buyfrom_system.setOnItemSelectedListener(new SystemSelectedListener(true));
    ed_default_me.setValue(EveDatabase.getDefaultME(null));
    ed_default_te.setValue(EveDatabase.getDefaultTE(null));
  }
  private void loadIdentity() {
    if (identitySelected.getProfileImage() != null) {
      Bitmap bitmap = null;
      if (identitySelected.getProfileImage().length > 0) {
        bitmap =
            BitmapFactory.decodeByteArray(
                identitySelected.getProfileImage(), 0, identitySelected.getProfileImage().length);
        //                bitmap = Bitmap.createScaledBitmap(bitmap, fanImage.getWidth(),
        // fanImage.getHeight(), true);
      } else {
        bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_profile_male);

        // Picasso.with(getActivity()).load(R.drawable.profile_image).into(fanImage);
      }
      bitmap = Bitmap.createScaledBitmap(bitmap, 100, 100, true);
      fanImageByteArray = toByteArray(bitmap);
      fanImage.setImageDrawable(ImagesUtils.getRoundedBitmap(getResources(), bitmap));
    }
    mFanExternalUserName.setText(identitySelected.getUsername());
    //  mFanExternalPassword.setText(identitySelected.getApiToken());
    List<String> arraySpinner = ExternalPlatform.getArrayItems();
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, arraySpinner);
    mFanExternalPlatform.setAdapter(adapter);
    ExternalPlatform[] externalPlatforms = ExternalPlatform.values();
    for (int i = 0; i < externalPlatforms.length; i++) {
      if (externalPlatforms[i] == identitySelected.getExternalPlatform()) {
        mFanExternalPlatform.setSelection(i);
        break;
      }
    }
  }
예제 #8
0
  // intent投げ先activitiesをspinnerに積む処理
  private void buildBrowserSpinner() {

    // アダプターを設定します
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mWdgSpinnerBrowsers = (Spinner) findViewById(R.id.SpinnerBrowsers);
    mWdgSpinnerBrowsers.setAdapter(adapter);
    // アイテムを追加します
    mSuitableApps = getSuitableActivities();
    for (int i = 0; i < mSuitableApps.size(); i++) {
      adapter.add(mSuitableApps.get(i).get("label"));
    }
    // スピナーのアイテムが選択された時に呼び出されるコールバックを登録します
    mWdgSpinnerBrowsers.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            // Spinner spinner = (Spinner) parent;
            // 選択されたアイテムを取得します
            // String item = (String) spinner.getSelectedItem();
            // Log.d(TAG, "spb:sel:" + item);
          }

          public void onNothingSelected(AdapterView<?> parent) {}
        });

    // スピナー表示時タイトル
    mWdgSpinnerBrowsers.setPrompt((CharSequence) getString(R.string.spinnerPrompt_browser));

    return;
  }
예제 #9
0
  private Style getSelectedStyleFromSpinner() {
    Spinner styleSpinner = (Spinner) findViewById(R.id.spinner_style);

    switch ((int) styleSpinner.getSelectedItemId()) {
      case 0:
        {
          return Style.ALERT;
        }

      case 1:
        {
          return Style.CONFIRM;
        }

      case 2:
        {
          return Style.INFO;
        }

      default:
        {
          return null;
        }
    }
  }
예제 #10
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_contato);

    database = Jpdroid.getInstance();

    etContato = (EditText) findViewById(R.id.etContato);
    spTipo = (Spinner) findViewById(R.id.spTipoContato);
    spTipo.setOnItemSelectedListener(evento);

    adquirirTipoContato();

    Intent it = getIntent();
    Serializable param = it.getExtras().getSerializable("contato");
    if (param != null) {
      posicao = it.getIntExtra("posicao", 0);
      Contato novo = (Contato) param;
      contato = novo;
      etContato.setText(contato.getContato());
      spTipo.setSelection((Long.valueOf(contato.getIdTipoContato()).intValue() - 1));

    } else {
      contato = new Contato();
    }
  }
예제 #11
0
 public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
   if (spTipo.getSelectedItem().equals("Celular")) {
     etContato.setInputType(InputType.TYPE_CLASS_PHONE);
   } else if (spTipo.getSelectedItem().equals("E-mail")) {
     etContato.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
   }
 }
  public void cancel(View v) {
    // settext = ''
    edtFname.setText("");
    edtLname.setText("");
    edtEmail.setText("");
    edtAge.setText("");

    // set button color = blue
    btnAge.setBackgroundResource(R.drawable.button_custom);
    btnDob.setBackgroundResource(R.drawable.button_custom);
    btnUnborn.setBackgroundResource(R.drawable.button_custom);
    btnMale.setBackgroundResource(R.drawable.maleselector);
    btnFemale.setBackgroundResource(R.drawable.femaleselector);

    btnAge.setTextColor(Color.WHITE);
    btnDob.setTextColor(Color.WHITE);
    btnUnborn.setTextColor(Color.WHITE);
    // btnMale.setTextColor(Color.WHITE);
    // btnFemale.setTextColor(Color.WHITE);

    // reset visibility
    spYear.setVisibility(View.INVISIBLE);
    spMonth.setVisibility(View.INVISIBLE);
    spDay.setVisibility(View.INVISIBLE);
    edtAge.setVisibility(View.INVISIBLE);

    Intent i = new Intent(Profile_Edit.this, Profile_view.class);
    i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    i.putExtra("EXIT", true);
    this.startActivity(i);
    // finish();

  }
예제 #13
0
  public void setZipcodeAdapter() {

    Log.d(Constants.LOG_TAG, "Setting zip code adapter " + Constants.zipcodes.size());

    zipcodeStaticText.setVisibility(View.GONE);
    zipcode.setVisibility(View.VISIBLE);
    zipcode.setAdapter(
        new ArrayAdapter<String>(
            getActivity().getApplicationContext(),
            R.layout.row_spinner_layout,
            Constants.zipcodes));
    zipcode.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {

            String zipcodeValueFromSpinner = zipcode.getSelectedItem().toString();
            String id = Constants.zipcodesMap.get(zipcodeValueFromSpinner);
            populateAreas(id);
          }

          @Override
          public void onNothingSelected(AdapterView<?> adapterView) {}
        });
  }
  private void CarregarSpinnerCategorias() {
    List<String> status = new ArrayList<>();
    status.add("Todos");
    status.add(Constantes.DESCRICAO_TIPO_CATEGORIA_DESPESA);
    status.add(Constantes.DESCRICAO_TIPO_CATEGORIA_RECEITA);

    ArrayAdapter<String> arrayAdapter =
        new ArrayAdapter(this, android.R.layout.simple_spinner_item, status);

    arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spnTipoCategoria.setAdapter(arrayAdapter);

    spnTipoCategoria.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            CarregarListaDeCategorias();
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });

    spnTipoCategoria.setSelection(0);
  }
  @Override
  protected void startDemo() {
    getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-25, 143), 4));

    // Set up the spinner/dropdown list
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    ArrayAdapter<CharSequence> adapter =
        ArrayAdapter.createFromResource(
            this, R.array.heatmaps_datasets_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(new SpinnerActivity());

    try {
      mLists.put(
          getString(R.string.police_stations),
          new DataSet(readItems(R.raw.police), getString(R.string.police_stations_url)));
      mLists.put(
          getString(R.string.medicare),
          new DataSet(readItems(R.raw.medicare), getString(R.string.medicare_url)));
    } catch (JSONException e) {
      Toast.makeText(this, "Problem reading list of markers.", Toast.LENGTH_LONG).show();
    }

    // Make the handler deal with the map
    // Input: list of WeightedLatLngs, minimum and maximum zoom levels to calculate custom
    // intensity from, and the map to draw the heatmap on
    // radius, gradient and opacity not specified, so default are used
  }
  /** Set up spinner navigation with swiped pages */
  private void setUpNavigation() {
    // Navigation spinner in toolbar for trainings selection
    LayoutInflater.from(mToolbar.getContext()).inflate(R.layout.navigation_spinner, mToolbar, true);
    mNavigationSpinner = (Spinner) mToolbar.findViewById(R.id.navigation_spinner);
    mNavigationSpinner.setOnItemSelectedListener(this);
    mNavigationSpinner.setSelection(mPosition);

    String[] from = new String[] {Trainings.EXERCISE};
    int[] to = new int[] {R.id.title};
    mNavigationAdapter =
        new NavigationAdapter(
            mToolbar.getContext(), R.layout.navigation_spinner_item, null, from, to, 0);
    mNavigationAdapter.setDropDownViewResource(R.layout.navigation_spinner_dropdown_item);
    mNavigationSpinner.setAdapter(mNavigationAdapter);

    // ViewPager for swipe navigation and animation on training select
    mViewPager.setOnPageChangeListener(this);
    mPagerAdapter = new TrainingPagerAdapter(getChildFragmentManager(), null);
    mViewPager.setAdapter(mPagerAdapter);

    Loader<Cursor> loader = getLoaderManager().getLoader(0);
    if (loader != null && !loader.isReset()) {
      getLoaderManager().restartLoader(0, null, this);
    } else {
      getLoaderManager().initLoader(0, null, this);
    }
  }
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();

    this.dialView = inflater.inflate(R.layout.means_select_color, null);

    Spinner lsColors = (Spinner) dialView.findViewById(R.id.lstColors);
    lsColors.setAdapter(new SpinnerColorAdapter(this.getContext(), null));

    final Button validMean = (Button) this.dialView.findViewById(R.id.btn_valid_color);
    validMean.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Spinner lsColors = (Spinner) dialView.findViewById(R.id.lstColors);
            String slcType = (String) lsColors.getSelectedItem();
            updateColor(slcType);
            dismiss();
          }
        });

    final Button cancelColor = (Button) this.dialView.findViewById(R.id.btn_cancel_color);
    cancelColor.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            dismiss();
          }
        });

    builder.setView(this.dialView);
    return builder.create();
  }
예제 #18
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View result = inflater.inflate(R.layout.activity_settings, container, false);

    mTitle = (TextView) result.findViewById(R.id.title);
    mTitle.setTypeface(getRobotoTypeface(RobotoTypefaces.LIGHT));

    mSelector = (Spinner) result.findViewById(R.id.selector);
    FiltersAdapter adapter = new FiltersAdapter(getActivity());
    mSelector.setAdapter(adapter);

    Bundle arguments = getArguments();
    if (arguments != null && arguments.containsKey(MainActivity.FILTER_NAME_EXTRA)) {
      String filterName = arguments.getString(MainActivity.FILTER_NAME_EXTRA);

      for (int i = 0; i < adapter.getCount(); i++) {
        if (filterName.equals(adapter.getItem(i))) {
          mSelector.setSelection(i);
          break;
        }
      }
    }
    return result;
  }
예제 #19
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final String[] datos = new String[] {"Elem1", "Elem2", "Elem3", "Elem4", "Elem5"};

    ArrayAdapter<String> adaptador =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, datos);

    cmbOpciones = (Spinner) findViewById(R.id.CmbOpciones);

    adaptador.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    cmbOpciones.setAdapter(adaptador);

    lblMensaje = (TextView) findViewById(R.id.lblMensaje);

    cmbOpciones.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          public void onItemSelected(
              AdapterView<?> parent, android.view.View v, int position, long id) {
            lblMensaje.setText("Seleccionado: " + parent.getItemAtPosition(position));
          }

          public void onNothingSelected(AdapterView<?> parent) {
            lblMensaje.setText("");
          }
        });
  }
  @Override
  public void handleResult(Result result) {
    String[] deliveryDetails = result.getContents().split(";");
    if (deliveryDetails.length == 2) {

      if (parse(deliveryDetails[0]) == 0) {
        Toast.makeText(this, "Invalid Order ID. Please scan again.", Toast.LENGTH_LONG).show();
        mScannerView.resumeCameraPreview(this);
      } else {
        mScannerView.stopCamera();
        setContentView(R.layout.activity_receipt_qr);
        drawing = (DrawingView) findViewById(R.id.drawingView);
        spinner = (Spinner) findViewById(R.id.spinner);
        spinner.setAdapter(adapter);

        spinner.setOnItemClickListener(
            new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                check_point = spinner.getItemAtPosition(i).toString();
              }
            });

        contentTxt = (TextView) findViewById(R.id.scanContent);
        contentTxt.setText(deliveryDetails[1].trim());
      }

    } else {
      Toast.makeText(this, "Invalid Code Format. Please scan again.", Toast.LENGTH_LONG).show();
      mScannerView.resumeCameraPreview(this);
    }
  }
예제 #21
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.settings);

    saveBoton = (Button) findViewById(R.id.button1);
    cancelBoton = (Button) findViewById(R.id.button2);

    et = (EditText) findViewById(R.id.editText1);

    prefs = getSharedPreferences("preferences", Context.MODE_PRIVATE);

    et.setText(String.valueOf(prefs.getLong("rad", 100)));

    spin = (Spinner) findViewById(R.id.spinner1);
    ArrayAdapter<CharSequence> adapter =
        ArrayAdapter.createFromResource(this, R.array.units, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spin.setAdapter(adapter);
    spin.setOnItemSelectedListener(new MyOnItemSelectedListener());

    saveBoton.setOnClickListener(new OnClickSaveListener());

    cancelBoton.setOnClickListener(new OnClickCancelListener());
  }
예제 #22
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_log, container, false);
    ButterKnife.bind(this, view);

    create();

    SpinnerAdapter mSpinnerAdapter1 =
        ArrayAdapter.createFromResource(
            getActivity(), R.array.log_types, android.R.layout.simple_spinner_dropdown_item);

    spinner.setAdapter(mSpinnerAdapter1);
    spinner.setSelection(logDetailLevel - 1);
    spinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            // burası ilk sefer boşa çalışmalı
            if (spinnerCountdown > 0) {
              spinnerCountdown--;
              return;
            }

            // detay seviyesi değiştirildiyse logları baştan yükle
            switch (position) {
              case 0:
                {
                  if (logDetailLevel != 1) {
                    logDetailLevel = 1;
                    refreshLogs();
                  }
                  break;
                }
              case 1:
                {
                  if (logDetailLevel != 2) {
                    logDetailLevel = 2;
                    refreshLogs();
                  }
                  break;
                }
              case 2:
                {
                  if (logDetailLevel != 3) {
                    logDetailLevel = 3;
                    refreshLogs();
                  }
                  break;
                }
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });

    return view;
  }
예제 #23
0
  private void ReloadChapterList() {

    String chapterlist[] = getResources().getStringArray(R.array.chapterlist);

    String chapter[] = Common.tokenFn("-1," + chapterlist[mBook], ",");

    ArrayList<HashMap<String, String>> mList = new ArrayList<HashMap<String, String>>();

    for (int y = 0; y < chapter.length; y++) {
      HashMap<String, String> item = new HashMap<String, String>();

      if (y == 0) {
        item.put("Chapter", "ALL");
      } else {
        item.put("Chapter", chapter[y]);
      }

      mList.add(item);
    }

    SimpleAdapter adapter =
        new SimpleAdapter(
            getBaseContext(),
            mList,
            android.R.layout.simple_spinner_item,
            new String[] {"Chapter"},
            new int[] {android.R.id.text1});
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
    Spinner chapter_spinner = (Spinner) findViewById(R.id.chapters);
    chapter_spinner.setAdapter(adapter);

    mChapter = 0;
    chapter_spinner.setSelection(mChapter);
    ReloadBibleContents();
  }
예제 #24
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    textView = (TextView) findViewById(R.id.text);
    spinner = (Spinner) findViewById(R.id.spinner);
    textView.setText("您选择城市是北京");
    // 1、设置数据源
    list = new ArrayList<String>();
    list.add("北京");
    list.add("上海");
    list.add("广州");
    list.add("深圳");

    // 2、新建ArrayAdapter(数组适配器)
    arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, list);

    // 3、arrayAdapter设置一个下拉列表样式
    arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    // 4、spinner加载适配器
    spinner.setAdapter(arrayAdapter);

    // 5、设置spinner监听器
    spinner.setOnItemSelectedListener(this);
  }
 @Override
 public void onClick(DialogInterface dialog, int which) {
   super.onClick(dialog, which);
   switch (which) {
     case DialogInterface.BUTTON_POSITIVE:
       final boolean isEditing = !isIncomplete();
       final SubtypeLocaleItem locale =
           (SubtypeLocaleItem) mSubtypeLocaleSpinner.getSelectedItem();
       final KeyboardLayoutSetItem layout =
           (KeyboardLayoutSetItem) mKeyboardLayoutSetSpinner.getSelectedItem();
       final InputMethodSubtype subtype =
           AdditionalSubtype.createAdditionalSubtype(locale.first, layout.first, ASCII_CAPABLE);
       setSubtype(subtype);
       notifyChanged();
       if (isEditing) {
         mProxy.onSavePressed(this);
       } else {
         mProxy.onAddPressed(this);
       }
       break;
     case DialogInterface.BUTTON_NEUTRAL:
       // Nothing to do
       break;
     case DialogInterface.BUTTON_NEGATIVE:
       mProxy.onRemovePressed(this);
       break;
   }
 }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.humidor_menu, menu);
    MenuItem item = menu.findItem(R.id.menuSort);
    spinner_sort = (Spinner) MenuItemCompat.getActionView(item);
    ArrayList<String> sortList = new ArrayList<String>();
    sortList.add("Sort By: Name");
    sortList.add("Sort By: Value");
    sortList.add("Sort By: Age");
    sortList.add("Sort By: Rating");

    CustomSpinnerAdapter spinSortAdapter = new CustomSpinnerAdapter(getActivity(), sortList);

    spinner_sort.setAdapter(spinSortAdapter);

    spinner_sort.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {

          @Override
          public void onItemSelected(AdapterView<?> adapter, View v, int position, long id) {
            String item = adapter.getItemAtPosition(position).toString();

            Toast.makeText(getActivity(), "Selected  : " + item, Toast.LENGTH_LONG).show();
          }

          @Override
          public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

          }
        });
  }
 /*
  * This method loads the data from the appropriate xml file
  */
 public void prepareData() {
   AssetManager manager = getAssets();
   InputStream is = null;
   int[] selectedIntValues =
       new int[] {
         categorySpinner.getSelectedItemPosition(), subcategorySpinner.getSelectedItemPosition()
       };
   String[] selectedStringValues = new String[selectedIntValues.length];
   for (int i = 0; i < selectedIntValues.length; i++) {
     if (selectedIntValues[i] < 10) {
       selectedStringValues[i] = "0" + selectedIntValues[i];
     } else {
       selectedStringValues[i] = "" + selectedIntValues[i];
     }
   }
   try {
     is =
         manager.open(
             "Category_"
                 + selectedStringValues[0]
                 + "/Shoplist_"
                 + selectedStringValues[1]
                 + ".xml");
   } catch (Exception e) {
     try {
       is = manager.open("empty_shoplist.xml");
     } catch (Exception e1) {
       // handle later
     }
   }
   handler = new MyXMLHandler(is);
 }
예제 #28
0
  // Allows for code reuse
  private void setLayoutContact() {
    setContentView(R.layout.snet_contact);
    currentLayout = R.layout.snet_contact;

    List<CharSequence> names = new ArrayList<CharSequence>();
    try {
      SNetDB461 database = new SNetDB461(pathName + "/" + mMyName + "snet.db");
      RecordSet<CommunityRecord> records = database.COMMUNITYTABLE.readAll();
      for (CommunityRecord rec : records) {
        names.add(rec.name.toString());
      }
      // Populates the list of names with those included in the community
      database.discard();
    } catch (DB461Exception e) {
      Log.e(TAG, "Failed to access the database");
    }
    // Sets up the spinner
    Spinner spinner = (Spinner) findViewById(R.id.memberspinner);
    ArrayAdapter<CharSequence> adapter =
        new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item, names);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(this);
    Log.d(TAG, "Setting the spinner");
  }
예제 #29
0
 public User getUser() {
   User user = new User();
   user.setId(
       (String)
           SPUtil.get(getActivity(), MyApp.PREF_TYPE_LOGIN, MyApp.LOGIN_ID, "", String.class));
   user.setUserName(userName.getText().toString());
   user.setTimeZone(0);
   user.setGender(userGender.getText().toString());
   String ageTxt = userAge.getText().toString();
   int age = 0;
   try {
     age = Integer.parseInt(ageTxt);
   } catch (NumberFormatException e) {
     age = 0;
   }
   user.setAge(age);
   user.setBirthday("");
   user.setCountryId(0);
   int homeId = originSpinner.getSelectedItemPosition() + 1;
   user.setHomeId(homeId);
   user.setBio(userBio.getText().toString());
   user.setSthInteresting(userDNA.getText().toString());
   user.setAmzExp(userTrophy.getText().toString());
   user.setToDo(userTodo.getText().toString());
   user.setPhilosophy(userPhilo.getText().toString());
   user.setFriendsDesc(userDesc.getText().toString());
   user.setInterest(userInterest.getText().toString());
   user.setLittleSecret(userSec.getText().toString());
   int langId = langSpinner.getSelectedItemPosition() + 1;
   user.setLangId(langId);
   user.setLocale("");
   return user;
 }
  // 选择城市
  private void chooseCity() {
    citySpinner.setPrompt("请选择城市");
    final SpinnerAdapter adapter =
        new SpinnerAdapter(this.context, dtoList.get(provinceSelectedIndex).getChilds());
    citySpinner.setAdapter(adapter);
    try {
      citySpinner.setSelection(citySelectedIndex);
    } catch (Exception e) {
    }
    citySpinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            cityTextView.setText(
                dtoList.get(provinceSelectedIndex).getChilds().get(position).getName());

            selectedAreaId = dtoList.get(provinceSelectedIndex).getChilds().get(position).getId();

            adapter.setSelectedIndex(position);

            citySelectedIndex = position;
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });

    citySpinner.performClick();
  }