コード例 #1
0
  @Override
  protected void onResume() {
    super.onResume();
    CustomElementManager.refresh(this);
    ArrayList<CustomElement> elements = CustomElementManager.getElementList();

    // Clear the existing list
    TableLayout tl = (TableLayout) findViewById(R.id.loads_container);
    tl.removeAllViews();

    // Go through and find all the save files and dynamically add them
    int length = elements.size();
    if (length != 0) {
      for (int i = 0; i < length; i++) {
        addEntity(elements.get(i).getName(), elements.get(i).getFilename());
      }
    } else {
      tr = new TableRow(this);
      tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
      tr.setGravity(Gravity.CENTER);

      TextView tv = new TextView(this);
      tv.setText(res.getText(R.string.no_elements));

      tr.addView(tv);
      tl.addView(tr);
    }
  }
コード例 #2
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.custom_element_manager_activity);
    res = getResources();

    Button createElementButton = (Button) findViewById(R.id.create_element_button);
    createElementButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            startActivity(
                new Intent(CustomElementManagerActivity.this, CustomElementActivity.class));
          }
        });
  }