コード例 #1
0
  protected void initVideoSpinners() {
    ArrayAdapter<CharSequence> adapter;

    // Video parameters spinners
    frameSizeSpinner = (Spinner) findViewById(R.id.frameSize_spinner);
    adapter =
        ArrayAdapter.createFromResource(
            this, R.array.frame_size_values, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    frameSizeSpinner.setAdapter(adapter);
    frameSizeSpinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            String[] frameSizeContainer =
                frameSizeSpinner.getSelectedItem().toString().split("x", 2);
            videoWidthOut = Integer.valueOf(frameSizeContainer[0].trim());
            videoHeightOut = Integer.valueOf(frameSizeContainer[1].trim());
          }

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

    videoBitRateSpinner = (Spinner) findViewById(R.id.videoBitRate_spinner);
    adapter =
        ArrayAdapter.createFromResource(
            this, R.array.video_bit_rate_values, android.R.layout.simple_spinner_item);
    videoBitRateSpinner.setAdapter(adapter);
    videoBitRateSpinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            videoBitRateInKBytes =
                Integer.valueOf(videoBitRateSpinner.getSelectedItem().toString());
          }

          @Override
          public void onNothingSelected(AdapterView<?> adapterView) {}
        });
  }
コード例 #2
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.masstab);

    spinnerFrom = (Spinner) findViewById(R.id.SpinnerFrom);
    ArrayAdapter<CharSequence> adapter =
        ArrayAdapter.createFromResource(
            this, R.array.weights, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerFrom.setAdapter(adapter);

    spinnerTo = (Spinner) findViewById(R.id.SpinnerTo);
    spinnerTo.setAdapter(adapter);

    final Button button = (Button) findViewById(R.id.Go_Button);
    button.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            calculate();
          }
        });
  }
コード例 #3
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    data = new SectorDataSource(this);
    data.open();

    // Get the spinners to use later
    Spinner systemList = (Spinner) findViewById(R.id.systemList);
    Spinner gridAplhaList = (Spinner) findViewById(R.id.gridAlphaList);
    Spinner gridNumList = (Spinner) findViewById(R.id.gridNumList);

    // Make sure we can update the information when something is selected
    systemList.setOnItemSelectedListener(this);
    gridAplhaList.setOnItemSelectedListener(this);
    gridNumList.setOnItemSelectedListener(this);

    // Load up the last selected sector
    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);

    // Pasted code begins here

    // Set up all the spinners. One for the system and another two for the coords. I hate how messy
    // this is
    ArrayAdapter<String> systemAdapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Static.systemList);
    systemAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    systemList.setAdapter(systemAdapter);

    // Load the letter selection
    ArrayAdapter<String> gridAlphaAdapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Static.alphaCoordList);
    gridAlphaAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    gridAplhaList.setAdapter(gridAlphaAdapter);

    // And finally load the number selector
    ArrayAdapter<String> gridNumAdapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Static.numCoordList);
    gridNumAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    gridNumList.setAdapter(gridNumAdapter);

    // GOGO super uber messy nested method calls and casts!
    systemList.setSelection(
        ((ArrayAdapter<String>) systemList.getAdapter())
            .getPosition(settings.getString(PREF_LAST_SYSTEM, "")));
    gridAplhaList.setSelection(
        ((ArrayAdapter<String>) gridAplhaList.getAdapter())
            .getPosition(settings.getString(PREF_LAST_SECTOR_APLHA, "")));
    gridNumList.setSelection(
        ((ArrayAdapter<String>) gridNumList.getAdapter())
            .getPosition(settings.getString(PREF_LAST_SECTOR_NUM, "")));

    // Add a listener to the add button
    ((Button) findViewById(R.id.button_add_mineral)).setOnClickListener(this);

    // Add the listener to the mineral list
    ((ListView) findViewById(R.id.oreList)).setOnItemClickListener(this);

    // Add the assigned minerals to the list
    Spinner oreSpinner = (Spinner) findViewById(R.id.mineralList);
    // Set up the list
    mineralList = new ArrayList<String>(Static.mineralList);
    // Add it all in
    mineralAdapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mineralList);
    mineralAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    oreSpinner.setAdapter(mineralAdapter);
  }