Exemplo n.º 1
0
 protected android.view.View onCreateDialogView() {
   android.widget.TableLayout.LayoutParams params;
   android.widget.TableLayout layout = new android.widget.TableLayout(mContext);
   layout.setPadding(6, 6, 6, 6);
   mSplashText = new android.widget.TextView(mContext);
   if (mDialogMessage != null) {
     mSplashText.setText(mDialogMessage);
   }
   android.widget.TableRow row_header = new android.widget.TableRow(mContext);
   row_header.addView(mSplashText);
   mPickInteger = new net.mandaria.tippytipper.widgets.NumberPicker(mContext);
   mPickInteger.setRange(mMin, mMax);
   android.widget.TextView suffix = new android.widget.TextView(mContext);
   suffix.setText(mSuffix);
   suffix.setTextSize(32);
   android.widget.TableRow row_one = new android.widget.TableRow(mContext);
   row_one.setGravity(Gravity.CENTER);
   row_one.addView(mPickInteger);
   row_one.addView(suffix);
   layout.addView(row_header);
   android.widget.TableLayout table_main = new android.widget.TableLayout(mContext);
   table_main.addView(row_one);
   android.widget.TableRow row_main = new android.widget.TableRow(mContext);
   row_main.setGravity(Gravity.CENTER_HORIZONTAL);
   row_main.addView(table_main);
   layout.addView(row_main);
   if (shouldPersist()) {
     mValue = getPersistedInt(mDefault);
   }
   bindData();
   return layout;
 }
Exemplo n.º 2
0
 public void addTableBody(TableLayout table) {
   Cursor cursor = mySQLiteHelper.executeQuery(this.buildTableQuery());
   int row = 0;
   if (cursor != null && cursor.moveToFirst()) {
     do {
       TableRow tr = new TableRow(getActivity());
       tr.setGravity(Gravity.CENTER);
       for (int i = 0; i < columnNames.length; i++) {
         String value = cursor.getString(cursor.getColumnIndex(columnNames[i]));
         TextView tv = getCellTextView(value, row);
         tr.addView(tv);
       }
       table.addView(tr);
       Long id = cursor.getLong(cursor.getColumnIndex("_id"));
       tr.setTag(id);
       tr.setOnClickListener(
           new View.OnClickListener() {
             @Override
             public void onClick(View v) {
               Long id = Long.valueOf(v.getTag().toString());
               String xml = formBuilder.buildFormSubmissionXMLString(form, id);
               ((FormDataActivity) getActivity()).switchToDisplayFormFragment(1, xml);
             }
           });
       row++;
     } while (cursor.moveToNext());
   }
 }
  @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);
    }
  }
Exemplo n.º 4
0
  public TableRow getTableTitleView() {
    TableRow rowTitle = new TableRow(getActivity());
    rowTitle.setGravity(Gravity.CENTER_HORIZONTAL);

    TextView title = new TextView(getActivity());
    title.setText(form.getTableName());

    title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    // title.setGravity(Gravity.CENTER);
    title.setTypeface(Typeface.SERIF, Typeface.BOLD);

    TableRow.LayoutParams params = new TableRow.LayoutParams();
    params.span = columnNames.length;

    rowTitle.addView(title, params);
    return rowTitle;
  }
Exemplo n.º 5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // 用代码创建TableLayout,设置宽度和高度
    TableLayout table = new TableLayout(this);
    TableLayout.LayoutParams params =
        new TableLayout.LayoutParams(
            TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT);

    table.setLayoutParams(params);
    for (int i = 1; i <= 10; i++) {
      // 用代码创建TableRow,设置宽度和高度
      TableRow.LayoutParams params1 =
          new TableRow.LayoutParams(
              TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
      TableRow row = new TableRow(this);
      row.setGravity(Gravity.CENTER);

      for (int j = 1; j <= 3; j++) {
        TableRow.LayoutParams trlp_in =
            new TableRow.LayoutParams(0, TableRow.LayoutParams.WRAP_CONTENT, 1);
        TextView view = new TextView(this);
        view.setText("行" + i + "列" + j);

        view.setLayoutParams(trlp_in);
        row.addView(view);
      }
      if (i % 2 == 0) {
        row.setBackgroundColor(Color.YELLOW);
      } else {
        row.setBackgroundColor(Color.BLUE);
      }

      table.addView(row, params1);
    }

    setContentView(table);
  }
Exemplo n.º 6
0
  void drawMinerUI() {
    View view = getView();

    if (view != null) {
      try {
        TableLayout t1 = (TableLayout) view.findViewById(R.id.minerStatlist);

        Activity activity = getActivity();

        TableRow tr1 = new TableRow(activity);
        TableRow tr2 = new TableRow(activity);
        TableRow tr3 = new TableRow(activity);

        TextView tvBTCRewards = new TextView(activity);
        TextView tvNMCRewards = new TextView(activity);
        TextView tvTotalHashrate = new TextView(activity);

        tr1.setGravity(Gravity.CENTER_HORIZONTAL);
        tr2.setGravity(Gravity.CENTER_HORIZONTAL);
        tr3.setGravity(Gravity.CENTER_HORIZONTAL);

        String RewardsBTC =
            "BTC Reward: "
                + CurrencyUtils.formatPayout(
                    data.getBalances().getBTC(), pref_widgetMiningPayoutUnit, "BTC");
        String RewardsNMC =
            "NMC Reward: "
                + CurrencyUtils.formatPayout(
                    data.getBalances().getNMC(), pref_widgetMiningPayoutUnit, "NMC");
        String Hashrate = "Total Hashrate: " + data.getHash_rate() + " MH/s\n";

        tvBTCRewards.setText(RewardsBTC);
        tvNMCRewards.setText(RewardsNMC);
        tvTotalHashrate.setText(Hashrate);

        tr1.addView(tvBTCRewards);
        tr2.addView(tvNMCRewards);
        tr3.addView(tvTotalHashrate);

        t1.addView(tr1);
        t1.addView(tr2);
        t1.addView(tr3);

        // End of Non-worker data
        List<Workers> workers = data.getWorkers();
        for (Workers worker : workers) {
          TableRow tr8 = new TableRow(activity);
          TableRow tr9 = new TableRow(activity);
          TableRow tr10 = new TableRow(activity);
          TableRow tr11 = new TableRow(activity);
          TableRow tr12 = new TableRow(activity);

          TextView tvMinerName = new TextView(activity);
          TextView tvHashrate = new TextView(activity);
          TextView tvAlive = new TextView(activity);
          TextView tvShares = new TextView(activity);
          TextView tvStales = new TextView(activity);

          tr8.setGravity(Gravity.CENTER_HORIZONTAL);
          tr9.setGravity(Gravity.CENTER_HORIZONTAL);
          tr10.setGravity(Gravity.CENTER_HORIZONTAL);
          tr11.setGravity(Gravity.CENTER_HORIZONTAL);
          tr12.setGravity(Gravity.CENTER_HORIZONTAL);

          tvMinerName.setText("Miner: " + worker.getName());
          float hashrate = worker.getHash_rate();
          tvHashrate.setText("Hashrate: " + Utils.formatDecimal(hashrate, 2, 0, false) + " MH/s");
          tvAlive.setText("Alive: " + (hashrate > 0.0));
          tvShares.setText(
              "Shares: "
                  + Utils.formatDecimal(worker.getWork().getBTC().getTotal_accepted(), 0, 0, true));
          tvStales.setText(
              "Stales: "
                  + Utils.formatDecimal(worker.getWork().getBTC().getTotal_rejected(), 0, 0, true));

          if (hashrate > 0.0) {
            tvMinerName.setTextColor(Color.GREEN);
          } else {
            tvMinerName.setTextColor(Color.RED);
          }

          tr8.addView(tvMinerName);
          tr9.addView(tvHashrate);
          tr10.addView(tvAlive);
          tr11.addView(tvShares);
          tr12.addView(tvStales);

          t1.addView(tr8);
          t1.addView(tr9);
          t1.addView(tr10);
          t1.addView(tr11);
          t1.addView(tr12);
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
Exemplo n.º 7
0
  public TableRow createRow(
      View image, String appName, String date, Double value, String reason, Context activity) {
    TableRow row = new TableRow(activity);
    row.setGravity(Gravity.CENTER);

    image.setPadding((int) (ratio * 10), 0, (int) (ratio * 15), 0);
    ((LinearLayout) image).setGravity(Gravity.LEFT);

    LinearLayout img = new LinearLayout(row.getContext());
    img.setLayoutParams(
        new LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    img.setOrientation(LinearLayout.HORIZONTAL);
    img.setGravity(Gravity.CENTER);
    img.addView(image);

    row.addView(
        img, new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, (int) (ratio * 70)));

    LinearLayout main = new LinearLayout(row.getContext());
    main.setLayoutParams(
        new LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    main.setOrientation(LinearLayout.VERTICAL);

    TextView appname = new TextView(activity);
    appname.setText(appName);
    appname.setPadding(0, 0, 0, 0);
    appname.setTextColor(Color.parseColor("#545859"));
    appname.setMaxLines(1);
    appname.setTextSize(16);
    appname.setLayoutParams(
        new LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));

    TextView movdate = new TextView(activity);
    // PARSE DATE AND SET TEXTVIEW
    try {
      SimpleDateFormat curFormater = new SimpleDateFormat("d-MMM-y HH:mm:ss", Locale.ENGLISH);
      curFormater.setTimeZone(TimeZone.getTimeZone("GMT"));
      Date endDate = curFormater.parse(date);
      curFormater.setTimeZone(TimeZone.getDefault());

      movdate.setText(
          DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, Locale.getDefault())
              .format(endDate));
      movdate.setPadding(0, 0, 0, 0);
      movdate.setTextColor(Color.parseColor("#787A77"));
      movdate.setTextSize(12);
    } catch (Exception e) {
      e.printStackTrace();
    }
    movdate.setLayoutParams(
        new LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));

    TextView movreason = new TextView(activity);
    Field field;
    try {
      field = (R.string.class.getField(reason));
      movreason.setText(activity.getString(field.getInt(R.string.class)));
    } catch (SecurityException e) {
    } catch (NoSuchFieldException e) {
    } catch (IllegalArgumentException e) {
    } catch (IllegalAccessException e) {
    }

    movreason.setPadding(0, 0, 0, 0);
    movreason.setTextColor(Color.parseColor("#545859"));
    movreason.setMaxLines(2);
    movreason.setTextSize(12);
    movreason.setLayoutParams(
        new LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));

    main.addView(appname);
    main.addView(movdate);
    main.addView(movreason);

    row.addView(
        main,
        new TableRow.LayoutParams(
            TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));

    LinearLayout position = new LinearLayout(row.getContext());
    position.setGravity(Gravity.CENTER);

    TextView movvalue = new TextView(activity);
    String textvalue;
    if (value > 0) textvalue = "+" + value; // String.format("%02d", (int)value);
    else textvalue = value.toString(); // String.format("%02d", (int)value);
    movvalue.setText(textvalue);
    movvalue.setPadding(0, 0, 0, 0);
    movvalue.setTextColor(Color.GRAY);
    movvalue.setTextSize(30);
    position.addView(movvalue);

    TableRow.LayoutParams params =
        new TableRow.LayoutParams(
            TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
    params.setMargins(0, 0, 10, 0);
    row.addView(position, params);

    return row;
  }
  private void GetAnswers(Integer _id) {

    openDatabaseConnection();

    String WhereStatement = "QUESTIONITEM " + "= " + String.valueOf(_id);
    String[] Columns = {"CORRECT", "ANSWERTEXT", "REASON"};

    Cursor c = myDbHelper.query("ANSWERS", Columns, WhereStatement, null, null, null, null);

    if (c.getCount() > 0) {

      c.moveToFirst();

      List<Answer> list = new ArrayList<Answer>();
      CorrectAnswerList = new ArrayList<Answer>();
      CorrectAnswerInHTMLList = new ArrayList<String>();
      do {
        Answer ans = new Answer();
        ans.set_Correct(c.getInt(c.getColumnIndex("CORRECT")));
        ans.set_AnswerText(c.getString(c.getColumnIndex("ANSWERTEXT")));
        ans.set_Reason(c.getString(c.getColumnIndex("REASON")));
        list.add(ans);
        // if the answer is correct keep the string in HTML
        if (ans.get_Correct() == 1) {
          String CorrectAnswerInHTML = ans.get_AnswerText();
          CorrectAnswerReasonInHTML = ans.get_Reason();
          CorrectAnswerList.add(ans); // Collection of correct answers
          CorrectAnswerInHTMLList.add(CorrectAnswerInHTML);
          CorrectAnswerInHTMLListCounter++;
        }
      } while (c.moveToNext());

      c.close();
      myDbHelper.close();

      // Add the number of Answer to the CorrectAnswerListCounter
      CorrectAnswerListCounter = CorrectAnswerList.size();

      // Initialize button array
      ButtonArray = new ArrayList<Button>();

      for (int current = 0; current < list.size(); current++) {
        Answer ThisAns = list.get(current);
        // Create a table row
        TableRow tr = new TableRow(this);
        tr.setId(1000 + current);
        tr.setGravity(Gravity.CENTER);

        tr.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

        /*TextView Tv = new TextView(this);
        Tv.setId(1000+current);
        Tv.setText(Html.fromHtml(ThisAns.get_AnswerText()));
        Tv.setTextColor(Color.WHITE);

           tr.addView(Tv);

           Table.addView(tr);*/

        // Configure each button and add to row and then add row to table
        Button bt = new Button(this);
        bt.setId(1000 + current);
        bt.setText(Html.fromHtml(ThisAns.get_AnswerText()));
        bt.setTextColor(Color.BLACK);
        bt.setGravity(Gravity.CENTER);
        bt.setWidth(420);
        bt.setHeight(LayoutParams.WRAP_CONTENT);
        bt.setTextSize(12);
        // Add the correct answer to the button
        bt.setTag(ThisAns.get_Correct());

        bt.setOnClickListener(this);
        // Add button the button array
        ButtonArray.add(bt);

        tr.addView(bt);

        Table.addView(tr);
      }
    }
  }
 private TableRow createRow() {
   TableRow row = new TableRow(this);
   row.setGravity(Gravity.CENTER);
   return row;
 }