Пример #1
0
  private void setMineralLists(Sector sector) {
    // Populate the list with the initial data
    // Remove the ones we don't want
    mineralList.clear();
    mineralList.addAll(Static.mineralList);

    // Grab the ore list for later
    ArrayAdapter<String> oreListAdapter =
        new ArrayAdapter<String>(
            this, android.R.layout.simple_list_item_1, new ArrayList<String>());
    ((ListView) findViewById(R.id.oreList)).setAdapter(oreListAdapter);

    // Add and remove the needed things from the lists
    for (Mineral mineral : sector.getMinerals()) {
      mineralList.remove(mineral.getMineral());

      oreListAdapter.add(mineral.getMineral());
    }

    // Check to see if the mineral list is empty. If so add the emtpy mineral
    if (mineralList.size() == 0) mineralList.add(emptyMineralString);

    mineralAdapter.notifyDataSetChanged();
    oreListAdapter.notifyDataSetChanged();
  }
Пример #2
0
 public void mOnClick(View v) {
   switch (v.getId()) {
     case R.id.btn3:
       mItem.clear();
       for (int i = 1001; i <= 1003; i++) {
         mItem.add(Integer.toString(i));
       }
       mAdapter.notifyDataSetChanged();
       break;
     case R.id.btn10:
       mItem.clear();
       for (int i = 1001; i <= 1010; i++) {
         mItem.add(Integer.toString(i));
       }
       mAdapter.notifyDataSetChanged();
       break;
     case R.id.btnalways:
       mList.setOverScrollMode(View.OVER_SCROLL_ALWAYS);
       break;
     case R.id.btnnever:
       mList.setOverScrollMode(View.OVER_SCROLL_NEVER);
       break;
     case R.id.btnifscroll:
       mList.setOverScrollMode(View.OVER_SCROLL_IF_CONTENT_SCROLLS);
       break;
   }
 }
Пример #3
0
 @Override
 public void onItemClick(AdapterView adapterView, View view, int position, long id) {
   Log.d(TAG, "onItemClick: position: " + position + ", id: " + id);
   String item = listAdapter.getItem(position).trim();
   if (item.endsWith(" =")) {
     item = item.substring(0, item.length() - 2);
   }
   if (!item.startsWith("no result")) {
     inputView.append(item);
   }
 }
  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) {}
        });
  }
Пример #5
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();
          }
        });
  }
Пример #6
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate");
    super.onCreate(savedInstanceState);
    Thread.currentThread().setUncaughtExceptionHandler(this);
    setContentView(R.layout.main);

    inputView = (EditText) findViewById(R.id.input_view);
    inputView.setOnEditorActionListener(this);

    listAdapter = new ArrayAdapter<String>(this, R.layout.row);
    listAdapter.setNotifyOnChange(true);

    resultsView = (ListView) this.findViewById(R.id.results_view);
    resultsView.setAdapter(listAdapter);
    resultsView.setOnItemClickListener(this);
  }
Пример #7
0
  @Override
  public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
    Log.d(TAG, "onEditorAction: actionId: " + actionId + ", keyEvent: " + keyEvent);

    if ((actionId == EditorInfo.IME_ACTION_DONE)
        || ((keyEvent != null) && (keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER))) {
      Log.d(TAG, "onEditorAction: IME_ACTION_DONE || KEYCODE_ENTER");
      String input = textView.getText().toString().trim();

      if (input.length() > 0) {
        String result = "";

        try {
          result += calculator.calculate(input);
        } catch (Exception e) {
          result = "no result (" + e.getMessage() + ")";
        }

        if (listAdapter.getCount() > 0) {
          listAdapter.add("");
        }

        listAdapter.add(input + " =");
        if (input.indexOf("@") > -1) {
          listAdapter.add(calculator.getEquation() + " =");
        }
        listAdapter.add(result);
        listAdapter.notifyDataSetChanged();

        inputView.endBatchEdit();
        inputView.setText("");
        hideKeyboard();
      }
    }

    return false;
  }
Пример #8
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);
  }
Пример #9
0
 public void clear() {
   inputView.setText("");
   listAdapter.clear();
   listAdapter.notifyDataSetChanged();
 }