コード例 #1
0
ファイル: FolderEx.java プロジェクト: neojsy/myapp
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.folderex);

    Intent gintent = getIntent();
    getPath = gintent.getStringExtra("path");
    dbPath = gintent.getStringExtra("dbpath");

    FileList _FileList = new FileList(this);
    _FileList.setOnPathChangedListener(_OnPathChanged);
    _FileList.setOnFileSelected(_OnFileSelected);

    LinearLayout layout = (LinearLayout) findViewById(R.id.LinearLayout01);
    layout.addView(_FileList);

    Util.print("getPath = " + getPath);
    String path = " ";

    if (getPath.equals("empty")) {
      File root = Environment.getExternalStorageDirectory();
      _FileList.setPath(root.getAbsolutePath());
      path = root.getAbsolutePath();
    } else {
      _FileList.setPath(getPath);
      path = getPath;
    }

    Util.print("path = " + path);

    _FileList.setFocusable(true);
    _FileList.setFocusableInTouchMode(true);

    ((TextView) findViewById(R.id.TextView01)).setSelected(true);
  }
コード例 #2
0
  @Override
  public void init(WindowBasedTextGUI textGUI) {
    final BasicWindow window = new BasicWindow("Grid layout test");

    final Panel leftPanel = new Panel();

    Panel checkBoxPanel = new Panel();
    for (int i = 0; i < 4; i++) {
      CheckBox checkBox = new CheckBox("Checkbox #" + (i + 1));
      checkBoxPanel.addComponent(checkBox);
    }

    Panel textBoxPanel = new Panel();
    textBoxPanel.addComponent(
        Panels.horizontal(new Label("Normal:   "), new TextBox(new TerminalSize(12, 1), "Text")));
    textBoxPanel.addComponent(
        Panels.horizontal(
            new Label("Password: "******"Text").setMask('*')));

    Panel buttonPanel = new Panel();
    buttonPanel.addComponent(
        new Button(
            "Enable spacing",
            new Runnable() {
              @Override
              public void run() {
                LinearLayout layoutManager = (LinearLayout) leftPanel.getLayoutManager();
                layoutManager.setSpacing(layoutManager.getSpacing() == 0 ? 1 : 0);
              }
            }));

    leftPanel.addComponent(checkBoxPanel.withBorder(Borders.singleLine("CheckBoxes")));
    leftPanel.addComponent(textBoxPanel.withBorder(Borders.singleLine("TextBoxes")));
    leftPanel.addComponent(buttonPanel.withBorder(Borders.singleLine("Buttons")));

    Panel rightPanel = new Panel();
    textBoxPanel = new Panel();
    TextBox readOnlyTextArea = new TextBox(new TerminalSize(16, 8));
    readOnlyTextArea.setReadOnly(true);
    readOnlyTextArea.setText(TestUtils.downloadGPL());
    textBoxPanel.addComponent(readOnlyTextArea);
    rightPanel.addComponent(textBoxPanel.withBorder(Borders.singleLine("Read-only")));
    rightPanel.setLayoutData(LinearLayout.createLayoutData(LinearLayout.Alignment.Fill));

    Panel contentArea = new Panel();
    contentArea.setLayoutManager(new LinearLayout(Direction.VERTICAL));
    contentArea.addComponent(Panels.horizontal(leftPanel, rightPanel));
    contentArea.addComponent(
        new Separator(Direction.HORIZONTAL)
            .setLayoutData(LinearLayout.createLayoutData(LinearLayout.Alignment.Fill)));
    contentArea.addComponent(
        new Button(
                "OK",
                new Runnable() {
                  @Override
                  public void run() {
                    window.close();
                  }
                })
            .setLayoutData(LinearLayout.createLayoutData(LinearLayout.Alignment.Center)));
    window.setComponent(contentArea);
    textGUI.addWindow(window);
  }
コード例 #3
0
ファイル: MainActivity.java プロジェクト: jreznot/diy-remote
    @Override
    protected void onPostExecute(List<Action> actions) {
      if (actions == null) {
        statusLabel.setText("Unable to get actions");
        return;
      }

      // all is ok, replace start pane
      LinearLayout contentPane = (LinearLayout) findViewById(R.id.contentPane);
      contentPane.removeView(startPane);

      LinearLayout buttonsLayout = new LinearLayout(getApplicationContext());
      buttonsLayout.setGravity(Gravity.CENTER);

      TableLayout buttonsTable = new TableLayout(getApplicationContext());
      TableRow currentTableRow = new TableRow(getApplicationContext());

      TableRow.LayoutParams buttonMarginParams =
          new TableRow.LayoutParams(
              TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
      int marginPx =
          (int)
              TypedValue.applyDimension(
                  TypedValue.COMPLEX_UNIT_DIP, 5, getResources().getDisplayMetrics());
      buttonMarginParams.setMargins(marginPx, marginPx, marginPx, marginPx);

      for (final Action action : actions) {
        ImageButton actionButton = new ImageButton(getApplicationContext());
        int drawableId = getResources().getIdentifier(action.icon, "drawable", getPackageName());
        actionButton.setImageDrawable(getResources().getDrawable(drawableId));
        actionButton.setContentDescription(action.description);
        actionButton.setLayoutParams(buttonMarginParams);
        actionButton.setBackgroundResource(R.drawable.button);
        actionButton.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                new PerformActionAsyncTask().execute(action.name);
              }
            });

        currentTableRow.addView(actionButton);
        if (currentTableRow.getChildCount() == 3) {
          buttonsTable.addView(currentTableRow);
          currentTableRow = new TableRow(getApplicationContext());
        }
      }

      if (currentTableRow.getChildCount() > 0) {
        buttonsTable.addView(currentTableRow);
      }

      buttonsLayout.addView(buttonsTable);

      LinearLayout.LayoutParams params =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
      contentPane.addView(buttonsLayout, params);

      runStatusUpdateTimer();
    }