Exemplo n.º 1
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;
   }
 }
Exemplo n.º 2
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();
  }
Exemplo n.º 3
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;
  }
Exemplo n.º 4
0
 public void clear() {
   inputView.setText("");
   listAdapter.clear();
   listAdapter.notifyDataSetChanged();
 }