示例#1
0
  public void bindView(Cursor cursor) {
    // Reinflate layout
    removeAllViewsInLayout();
    View view = LayoutInflater.from(getContext()).inflate(R.layout.sets_table, this);

    TableRow tableRowWeight = (TableRow) view.findViewById(R.id.tableRowWeight);
    TableRow tableRowReps = (TableRow) view.findViewById(R.id.tableRowReps);

    if (cursor != null && cursor.moveToFirst()) {
      do {
        TextView textViewWeight = new TextView(getContext());
        TextView textViewReps = new TextView(getContext());

        textViewWeight.setBackgroundResource(R.drawable.cell_right_border);
        textViewReps.setBackgroundResource(R.drawable.cell_right_top_border);

        textViewWeight.setPadding(4, 0, 5, 0);
        textViewReps.setPadding(4, 0, 5, 0);

        textViewWeight.setGravity(Gravity.CENTER_HORIZONTAL);
        textViewReps.setGravity(Gravity.CENTER_HORIZONTAL);

        tableRowWeight.addView(textViewWeight);
        tableRowReps.addView(textViewReps);

        // Bind data
        float weight = cursor.getFloat(cursor.getColumnIndex(Sets.WEIGHT));
        String reps = cursor.getString(cursor.getColumnIndex(Sets.REPS));

        textViewWeight.setText(SetUtils.weightFormat(weight));
        textViewReps.setText(reps);
      } while (cursor.moveToNext());
    }
  }
  private void addTableRow(TableLayout table, String parameter, String value) {

    TableRow row = new TableRow(table.getContext());

    TableRow.LayoutParams trParams = new TableRow.LayoutParams();
    trParams.setMargins(2, 2, 2, 1);
    row.setLayoutParams(trParams);
    row.setBackgroundColor(Color.rgb(0x00, 0x00, 0x00));

    TextView text1 = new TextView(row.getContext());
    text1.setTextSize(18);
    text1.setText(parameter);
    text1.setBackgroundColor(Color.rgb(0x18, 0x18, 0x18));
    text1.setLayoutParams(trParams);
    text1.setPadding(5, 0, 0, 0);
    row.addView(text1);

    TextView text2 = new TextView(row.getContext());
    text2.setTextSize(18);
    text2.setText(value);
    text2.setBackgroundColor(Color.rgb(0x18, 0x18, 0x18));
    text2.setLayoutParams(trParams);
    text2.setPadding(5, 0, 0, 0);
    row.addView(text2);

    table.addView(row);
  }
示例#3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    LinearLayout myLayout = new LinearLayout(this);
    myLayout.setOrientation(LinearLayout.VERTICAL);

    input1 = new EditText(this);
    output1 = new TextView(this);

    button1 = new Button(this);

    bannerText = new TextView(this);

    myLayout.setOrientation(LinearLayout.VERTICAL);
    myLayout.setGravity(Gravity.CENTER_HORIZONTAL);
    myLayout.setBackgroundColor(Color.LTGRAY);

    bannerText.setWidth(300);
    bannerText.setGravity(Gravity.CENTER_HORIZONTAL);
    bannerText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 50);
    bannerText.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
    bannerText.setText(" Currency Converter from Dollar $ to Birr");
    bannerText.setTextColor(Color.BLUE);
    bannerText.setPadding(0, 0, 0, 10);

    input1.setHint("Enter Dollar amount");
    button1.setText("Convert to Birr!");

    output1.setText("0");
    output1.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
    output1.setPadding(0, 20, 0, 20);
    output1.setWidth(150);
    output1.setGravity(Gravity.CENTER_HORIZONTAL);
    output1.setTextColor(Color.WHITE);

    // button1.setOnClickListener(myListener);

    button1.setOnClickListener(this);

    myLayout.addView(bannerText);
    myLayout.addView(input1);
    myLayout.addView(output1);

    myLayout.addView(button1);

    LinearLayout.LayoutParams parm = new RadioGroup.LayoutParams(300, 100);

    input1.setLayoutParams(parm);
    output1.setLayoutParams(parm);
    button1.setLayoutParams(parm);

    setContentView(myLayout);

    input1.setLayoutParams(new LinearLayout.LayoutParams(225, 50));
    button1.setLayoutParams(new LinearLayout.LayoutParams(170, 50));
    // button2.setLayoutParams(new LinearLayout.LayoutParams(170, 50));

  }
示例#4
0
 public void addItem(Item item) {
   int size = icon + padding + padding;
   ViewGroup.LayoutParams params =
       new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, size);
   TextView row = new TextView(getContext());
   row.setId(item.getId());
   row.setLayoutParams(params);
   row.setMaxLines(1);
   row.setEllipsize(TextUtils.TruncateAt.END);
   row.setGravity(Gravity.CENTER_VERTICAL);
   row.setText(item.getTitle());
   row.setTypeface(Typeface.DEFAULT_BOLD);
   row.setOnClickListener(this);
   row.setTextColor(BottomUtils.colorStateListText(getContext()));
   TypedValue typedValue = new TypedValue();
   getContext()
       .getTheme()
       .resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true);
   row.setBackgroundResource(typedValue.resourceId);
   if (item.getIcon() != null) {
     row.setCompoundDrawablesWithIntrinsicBounds(icon(item.getIcon()), null, null, null);
     row.setCompoundDrawablePadding(padding);
     row.setPadding(padding, padding, padding, padding);
   } else {
     row.setPadding(size, padding, padding, padding);
   }
   container.addView(row);
 }
  public TextView getItem(int index) {
    String text = "";
    if (isIndexValid(index)) {
      text = list.get(index);
    } else {
      text = "";
    }
    TextView textView = new TextView(context);
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, 80);
    textView.setLayoutParams(params);
    if (index == currentIndex) {
      textView.setPadding(10, 10, 10, 10);
      textView.setTextSize(30);
    } else {
      textView.setPadding(10, 10, 10, 10);
      textView.setTextSize(22);
    }
    textView.setTag(index);
    textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
    textView.setText(text);
    textView.setTextColor(getResources().getColor(R.color.belizehole80));
    textView.setOnClickListener(this);

    return textView;
  }
示例#6
0
  private void dibujarCheck() {

    contenido.removeAllViews();

    for (Modulo m : modulos) {
      TextView mTitulo = new TextView(this);
      mTitulo.setText(m.getName());
      mTitulo.setBackgroundColor(Color.parseColor("#226666"));
      mTitulo.setTextColor(Color.WHITE);
      mTitulo.setLayoutParams(
          new LinearLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
      mTitulo.setPadding(0, 6, 0, 6);
      mTitulo.setGravity(Gravity.CENTER_HORIZONTAL);
      contenido.addView(mTitulo);

      LinearLayout itemLayout = new LinearLayout(this);
      itemLayout.setLayoutParams(
          new LinearLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
      itemLayout.setBackgroundResource(R.drawable.fondo_1);
      itemLayout.setGravity(Gravity.CENTER_HORIZONTAL);
      itemLayout.setOrientation(LinearLayout.VERTICAL);
      itemLayout.setPadding(16, 5, 16, 5);

      for (cl.tdc.felipe.tdc.objects.Relevar.Item item : m.getItems()) {
        TextView iTitulo = new TextView(this);
        iTitulo.setText(item.getName());
        iTitulo.setBackgroundColor(Color.GREEN);
        iTitulo.setLayoutParams(
            new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        iTitulo.setPadding(0, 8, 0, 4);
        iTitulo.setGravity(Gravity.CENTER_HORIZONTAL);

        View vista = getView(m.getId(), item);
        if (vista == null) continue;

        itemLayout.addView(iTitulo);
        itemLayout.addView(vista);
        vistas.add(vista);
      }

      contenido.addView(itemLayout);
    }

    Button agregarFoto = new Button(this);
    agregarFoto.setText("Agregar Foto");
    agregarFoto.setBackgroundResource(R.drawable.custom_button_rounded_green);
    agregarFoto.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            imgTmp = new FormImage();
            imgTmp.setIdSystem(estaciones.get(station.getSelectedItemPosition()).getId());
            tomarFoto();
          }
        });
    contenido.addView(agregarFoto);
  }
  public HierarchyElementView(Context context, HierarchyElement it) {
    super(context);

    setColor(it.getColor());

    mIcon = new ImageView(context);
    mIcon.setImageDrawable(it.getIcon());
    mIcon.setId(1);
    mIcon.setPadding(0, 15, 5, 0);
    addView(
        mIcon,
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    mPrimaryTextView = new TextView(context);
    mPrimaryTextView.setTextAppearance(context, android.R.style.TextAppearance_Large);
    mPrimaryTextView.setText(it.getPrimaryText());
    mPrimaryTextView.setPadding(0, 7, 0, 0);
    mPrimaryTextView.setId(2);
    LayoutParams l =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    l.addRule(RelativeLayout.RIGHT_OF, mIcon.getId());
    addView(mPrimaryTextView, l);

    mSecondaryTextView = new TextView(context);
    mSecondaryTextView.setText(it.getSecondaryText());
    mSecondaryTextView.setPadding(0, 0, 0, 7);
    mSecondaryTextView.setTextAppearance(context, android.R.style.TextAppearance_Small);
    LayoutParams lp =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.BELOW, mPrimaryTextView.getId());
    lp.addRule(RelativeLayout.RIGHT_OF, mIcon.getId());
    addView(mSecondaryTextView, lp);
  }
示例#8
0
  public PageView(Context context) {
    super(context);
    _uihandler = new Handler(Looper.getMainLooper());
    _animationView = new SimpleAnimationView(context, this);

    _textView = new TextView(context);
    _textView.setTextColor(Color.BLACK);
    _textView.setGravity(Gravity.LEFT);
    _textView.setPadding(20, 0, 0, 0);
    _textView.setText("" + _pageindex);

    _timeView = new TextView(context);

    _timeView.setTextColor(Color.BLACK);
    _timeView.setGravity(Gravity.RIGHT);
    _timeView.setPadding(0, 0, 20, 0);
    _timer = new Timer();
    _timer.schedule(new TimeViewTimerTask(), 1000, 2000);

    _batteryview = new ImageView(context);
    _batteryview.setBackgroundColor(Color.TRANSPARENT);
    Bitmap b = Bitmap.createBitmap(100, 50, Config.ARGB_8888);

    BitmapUtil.DrawBatteryBitmap(b, 0, 0);
    _batteryview.setImageBitmap(b);
    addView(_animationView);
    addView(_textView);
    addView(_timeView);
    addView(_batteryview);
  }
  private void addMessageToLayout(Message message) {
    TextView user = new TextView(this);
    TextView messageView = new TextView(this);

    user.setTextColor(getResources().getColor(R.color.messageTitle));
    user.setText(
        "("
            + DateFormat.format("hh:mm aa", message.getTimestamp())
            + ") "
            + message.getUsername()
            + ":");
    user.setTextSize(15);
    user.setPadding(5, 15, 5, 0);
    user.setTypeface(Typeface.DEFAULT_BOLD);

    messageView.setText(message.getContent());
    messageView.setTextColor(getResources().getColor(R.color.textColor));
    messageView.setTextSize(15);
    messageView.setPadding(5, 0, 5, 0);

    View line = new View(this);
    line.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 1));
    line.setBackgroundColor(getResources().getColor(R.color.messageLine));
    line.setPadding(0, 0, 0, 15);

    messages.addView(user);
    messages.addView(messageView);
    messages.addView(line);
  }
  public TableLayout createTable() {
    int comboCounter = 0;
    TableLayout tl = new TableLayout(this);
    TableRow tr = new TableRow(this);
    CheckBox c;
    TextView text;
    for (int x = 0; x < KMapControl.getTopDisplay().length; x++) {
      text = new TextView(this);
      if (KMapControl.getKMapSize() == KMapController.VARIABLE_5) {
        if (x == 0) {
          fiveVarCounter += 1;
          text.setTextColor(Color.YELLOW);
          text.setText(fiveVarCounter + "  ");
        } else text.setText(KMapControl.getTopDisplay()[x]);
      } else {
        text.setText(KMapControl.getTopDisplay()[x]);
      }
      text.setPadding(PADDING, PADDING, PADDING, PADDING);
      tr.addView(text);
    }
    tl.addView(tr);

    for (int x = 0; x < KMapControl.getLeftDisplay().length; x++) {
      tr = new TableRow(this);
      text = new TextView(this);
      text.setText(KMapControl.getLeftDisplay()[x]);
      text.setPadding(PADDING, PADDING, PADDING, PADDING);
      tr.addView(text);

      for (int y = 1; y < KMapControl.getTopDisplay().length; y++) {
        c = new CheckBox(this);
        if (KMapControl.getKMapSize() == KMapController.VARIABLE_5 && fiveVarCounter == 1)
          c.setId(KMapControl.getTableLayout()[comboCounter] + 16);
        else c.setId(KMapControl.getTableLayout()[comboCounter]);
        c.setButtonDrawable(R.drawable.customcheck);
        c.setPadding(PADDING, PADDING, PADDING, PADDING);

        c.setOnCheckedChangeListener(
            new OnCheckedChangeListener() {

              @Override
              public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
                KMapControl.setVariableAtLocation(arg0.getId(), arg1);
                String s = "\nLast Selected:\n\nMinterm: " + arg0.getId() + "\n" + "State: ";
                if (arg1 == false) s += "0";
                else s += "1";
                s += "\nBinary: " + KMapControl.getBinarySpot(arg0.getId());
                s += "\nVariables: " + KMapControl.getStringVariableAtLocation(arg0.getId());
                display.setText(s);
              }
            });
        tr.addView(c);
        comboCounter += 1;
      }
      tl.addView(tr);
    }
    return tl;
  }
  public void setTable(Integer i) {
    final Integer index = i;
    TableRow row = new TableRow(getActivity().getApplicationContext());
    TableRow.LayoutParams lp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT);
    row.setLayoutParams(lp);

    final TextView cp = new Button(getActivity().getApplicationContext());
    cp.setAllCaps(false);
    cp.setText(wordRecordArrayList.get(i).getchin_word());
    //        cp.setText(i.toString());
    cp.setPadding(20, 0, 30, 0);
    cp.setBackgroundResource(R.drawable.borders_black_and_blue);
    cp.setTextSize(40);
    cp.setGravity(Gravity.CENTER);
    row.addView(cp);

    TextView tone = new TextView(getActivity().getApplicationContext());
    tone.setText(wordRecordArrayList.get(i).getTone().toString());
    tone.setTextSize(30);
    tone.setPadding(100, 0, 30, 0);
    tone.setTextColor(Color.BLACK);
    row.addView(tone);

    TextView turnOff = new TextView(getActivity().getApplicationContext());
    turnOff.setText("關閉");
    turnOff.setTextSize(15);
    turnOff.setPadding(100, 0, 30, 0);
    turnOff.setTextColor(Color.BLACK);
    turnOff.setGravity(Gravity.CENTER);
    turnOff.setVisibility(View.INVISIBLE);
    row.addView(turnOff);

    Switch switch1 = new Switch(getActivity().getApplicationContext());
    switch1.setSwitchMinWidth(200);
    switch1.setPadding(0, 0, 0, 0);
    switch1.setGravity(Gravity.CENTER);
    switch1.setVisibility(View.INVISIBLE);
    if (wordRecordArrayList.get(i).getAvailable().intValue() == 1) {
      switch1.setChecked(true);
    } else {
      switch1.setChecked(false);
    }
    row.addView(switch1);

    TextView turnOn = new TextView(getActivity().getApplicationContext());
    turnOn.setText("開啟");
    turnOn.setTextSize(15);
    turnOn.setPadding(30, 0, 30, 0);
    turnOn.setTextColor(Color.BLACK);
    turnOn.setGravity(Gravity.CENTER);
    turnOn.setVisibility(View.INVISIBLE);
    row.addView(turnOn);

    delRecord(i, row, cp);
    setAvailability(row, turnOn, turnOff, switch1, index);
    tl_word.addView(row);
  }
示例#12
0
  private void updateUiFromCurrentStatus() {
    // if we have no status, do nothing
    if (statuses == null) return;

    // dynamically create the UI from the status objects
    LinearLayout container = (LinearLayout) findViewById(R.id.statuses);
    container.removeAllViews();
    for (int i = 0; i < statuses.size(); i++) {
      // here, we dynamically create the various text elements and add them to our container
      com.districttaco.android.Status status = statuses.get(i);
      TextView locationName = new TextView(this);
      locationName.setText(status.getLocationName());
      locationName.setTextAppearance(this, R.style.StatusHeader);
      container.addView(locationName);
      TextView locationDescription = new TextView(this);
      locationDescription.setText(status.getLocationDescription());
      locationDescription.setTextAppearance(this, R.style.StatusContent);
      locationDescription.setPadding(12, 0, 0, 0);
      container.addView(locationDescription);
      TextView special = new TextView(this);
      special.setText(R.string.special);
      special.setTextAppearance(this, R.style.StatusHeader);
      container.addView(special);
      TextView statusDetail = new TextView(this);
      statusDetail.setText(status.getStatusText());
      statusDetail.setTextAppearance(this, R.style.StatusContent);
      statusDetail.setPadding(12, 0, 0, 0);
      container.addView(statusDetail);
      TextView infoHeader = new TextView(this);
      infoHeader.setText(status.getInfoHeader());
      infoHeader.setTextAppearance(this, R.style.InfoHeader);
      infoHeader.setPadding(0, 16, 0, 0);
      container.addView(infoHeader);
      TextView infoTitle = new TextView(this);
      infoTitle.setText(status.getInfoTitle());
      infoTitle.setTextAppearance(this, R.style.StatusHeader);
      container.addView(infoTitle);
      TextView infoBody = new TextView(this);
      infoBody.setText(status.getInfoBody());
      infoBody.setTextAppearance(this, R.style.StatusContent);
      infoBody.setPadding(12, 0, 0, 0);
      container.addView(infoBody);
    }

    // update last fetch time
    if (lastFetch != null) {
      TextView lastUpdate = new TextView(this);
      SimpleDateFormat formatter = new SimpleDateFormat(getString(R.string.date_format));
      lastUpdate.setText(formatter.format(lastFetch));
      lastUpdate.setTextAppearance(this, R.style.Footer);
      container.addView(lastUpdate);
    }
  }
  private void BuildTable(int rows, int cols) {

    try {

      // outer for loop
      for (int i = 1; i <= rows; i++) {

        TableRow row = new TableRow(getActivity());
        row.setBackgroundResource(R.drawable.layout_border5);

        /* row.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,
                                TableRow.LayoutParams.WRAP_CONTENT));
        */
        TableRow.LayoutParams params =
            new TableRow.LayoutParams(
                TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
        params.setMargins(2, 2, 0, 0);
        row.setLayoutParams(params);

        // inner for loop
        for (int j = 1; j <= cols; j++) {

          TextView tv = new TextView(getActivity());
          tv.setLayoutParams(
              new TableRow.LayoutParams(
                  TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
          // tv.setBackgroundResource(R.drawable.cell_shape);
          if (j == 1) {
            tv.setPadding(40, 5, 10, 10);
          } else {
            tv.setPadding(80, 10, 10, 14);
          }

          try {
            tv.setText("   " + monthlyOrders.get(i - 1));
          } catch (Exception e) {
            e.printStackTrace();
          }
          if (j == 2) {
            tv.setText("   " + orders_inprogress.get(i - 1));
          }
          if (j == 3) {
            tv.setText("   " + orders_completed.get(i - 1));
          }
          row.addView(tv);
        }

        table_layout.addView(row);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
示例#14
0
  public CommentSubThreadView(
      final AppCompatActivity activity, final PostCommentListingURL url, int messageRes) {

    super(activity);

    mUrl = url;

    final TypedArray attr =
        activity.obtainStyledAttributes(
            new int[] {
              R.attr.rrCommentSpecificThreadHeaderBackCol,
              R.attr.rrCommentSpecificThreadHeaderTextCol
            });

    final int rrCommentSpecificThreadHeaderBackCol = attr.getColor(0, 0);
    final int rrCommentSpecificThreadHeaderTextCol = attr.getColor(1, 0);

    attr.recycle();

    final TextView textView = new TextView(activity);
    textView.setText(messageRes);
    textView.setTextColor(rrCommentSpecificThreadHeaderTextCol);
    textView.setTextSize(15.0f);
    textView.setPadding(
        (int) (15 * dpScale), (int) (10 * dpScale), (int) (10 * dpScale), (int) (4 * dpScale));

    final TextView messageView = new TextView(activity);
    messageView.setText(R.string.comment_header_specific_thread_message);
    messageView.setTextColor(rrCommentSpecificThreadHeaderTextCol);
    messageView.setTextSize(12.0f);
    messageView.setPadding((int) (15 * dpScale), 0, (int) (10 * dpScale), (int) (10 * dpScale));

    final LinearLayout layout = new LinearLayout(activity);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.addView(textView);
    layout.addView(messageView);

    setContents(layout);
    setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);

    setBackgroundColor(rrCommentSpecificThreadHeaderBackCol);

    setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(final View v) {
            final PostCommentListingURL allComments = mUrl.commentId(null);
            LinkHandler.onLinkClicked(activity, allComments.toString());
          }
        });
  }
 public void updateFileExistIcon() {
   if (message != null && message.messageOwner.media != null) {
     String fileName = null;
     File cacheFile;
     if (message.messageOwner.attachPath == null
         || message.messageOwner.attachPath.length() == 0
         || !(new File(message.messageOwner.attachPath).exists())) {
       cacheFile = FileLoader.getPathToMessage(message.messageOwner);
       if (!cacheFile.exists()) {
         fileName = FileLoader.getAttachFileName(message.messageOwner.media.document);
       }
     }
     loaded = false;
     if (fileName == null) {
       statusImageView.setVisibility(INVISIBLE);
       dateTextView.setPadding(0, 0, 0, 0);
       loading = false;
       loaded = true;
       MediaController.getInstance().removeLoadingFileObserver(this);
     } else {
       MediaController.getInstance().addLoadingFileObserver(fileName, this);
       loading = FileLoader.getInstance().isLoadingFile(fileName);
       statusImageView.setVisibility(VISIBLE);
       statusImageView.setImageResource(
           loading ? R.drawable.media_doc_pause : R.drawable.media_doc_load);
       dateTextView.setPadding(
           LocaleController.isRTL ? 0 : AndroidUtilities.dp(14),
           0,
           LocaleController.isRTL ? AndroidUtilities.dp(14) : 0,
           0);
       if (loading) {
         progressView.setVisibility(VISIBLE);
         Float progress = ImageLoader.getInstance().getFileProgress(fileName);
         if (progress == null) {
           progress = 0.0f;
         }
         progressView.setProgress(progress, false);
       } else {
         progressView.setVisibility(INVISIBLE);
       }
     }
   } else {
     loading = false;
     loaded = true;
     progressView.setVisibility(INVISIBLE);
     progressView.setProgress(0, false);
     statusImageView.setVisibility(INVISIBLE);
     dateTextView.setPadding(0, 0, 0, 0);
     MediaController.getInstance().removeLoadingFileObserver(this);
   }
 }
  /** create dynamic table layout and fill it with data of activity index. */
  private void loadIndex() {

    // get dao
    Dao<LocationData, Integer> locationDao = null;

    int index = 1;
    int left = 3, top = 3, right = 3, bottom = 3;

    // first clean the table except first row
    table.removeViews(index, (table.getChildCount() - 1));

    // query for all of the data objects in the database
    List<LocationData> list;
    try {
      locationDao = getHelper().getLocationDao();
      list = locationDao.queryForAll();
      for (LocationData data : list) {

        TableRow row = new TableRow(this);

        TextView viewID = new TextView(this);
        viewID.setPadding(left, top, right, bottom);
        viewID.setText(data.getId().toString());
        row.addView(viewID);

        TextView viewLongitude = new TextView(this);
        viewLongitude.setPadding(left, top, right, bottom);
        viewLongitude.setText(String.valueOf(data.getLongitude()));
        row.addView(viewLongitude);

        TextView viewLatitude = new TextView(this);
        viewLatitude.setPadding(left, top, right, bottom);
        viewLatitude.setText(String.valueOf(data.getLatitude()));
        row.addView(viewLatitude);

        TextView viewTimestamp = new TextView(this);
        viewTimestamp.setPadding(left, top, right, bottom);
        viewTimestamp.setText(data.getTimestamp().toLocaleString());
        row.addView(viewTimestamp);

        table.addView(row, index);
        index++;
      }
    } catch (SQLException e) {
      Log.e(TAG, "Could not read data");
      e.printStackTrace();
    } finally {

    }
  }
示例#17
0
  private void createLayout(int value, int max, String text) {
    maxValue = max;

    RelativeLayout textValueLayout = new RelativeLayout(getContext());
    textValueLayout.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    textValueLayout.setPadding(0, Misc.densify(4), 0, Misc.densify(4));

    TextView sliderTextVal = new TextView(getContext());
    sliderTextVal.setText(text);
    sliderTextVal.setTextSize(TypedValue.COMPLEX_UNIT_SP, Misc.densify(6));
    sliderTextVal.setPadding(Misc.densify(16), Misc.densify(4), Misc.densify(4), Misc.densify(4));
    sliderTextVal.setTextColor(Color.parseColor("#2c2e2f"));
    RelativeLayout.LayoutParams localTextViewParams =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    localTextViewParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    sliderTextVal.setLayoutParams(localTextViewParams);

    sliderTitleVal = new TextView(getContext());
    sliderTitleVal.setTextSize(TypedValue.COMPLEX_UNIT_SP, Misc.densify(6));

    sliderTitleVal.setText(String.valueOf(value));
    sliderTitleVal.setTextColor(Color.parseColor("#2c2e2f"));
    sliderTitleVal.setPadding(0, Misc.densify(4), Misc.densify(16), Misc.densify(4));
    RelativeLayout.LayoutParams hueTitleValParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    hueTitleValParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    sliderTitleVal.setLayoutParams(hueTitleValParams);

    LinearLayout hueSliderLayout = new LinearLayout(getContext());
    hueSliderLayout.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    seekSlider = new HtcSeekBar(getContext());
    seekSlider.setMax(max);
    seekSlider.setOnSeekBarChangeListener(this);
    seekSlider.setProgress(value + (maxValue / 2));
    seekSlider.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    textValueLayout.addView(sliderTextVal);
    textValueLayout.addView(sliderTitleVal);
    hueSliderLayout.addView(seekSlider);

    addView(textValueLayout);
    addView(hueSliderLayout);

    return;
  }
示例#18
0
    public LetterView(Context context, char l) {
      super(context);
      this.letter = l;

      setClickable(true);
      setFocusable(true);

      text = new TextView(context);
      text.setBackgroundResource(R.drawable.keyboard_letter);
      text.setGravity(Gravity.CENTER);
      text.setTextSize(18);

      if (letter == BACKSPACE) {
        text.setText("");
        text.setCompoundDrawablesWithIntrinsicBounds(
            getContext().getResources().getDrawable(R.drawable.backspace), null, null, null);
        text.setCompoundDrawablePadding(0);
        text.setPadding(10, 0, 10, 0);
      } else if (letter == ' ') {
        text.setText("");
        text.setCompoundDrawablesWithIntrinsicBounds(
            getContext().getResources().getDrawable(R.drawable.space), null, null, null);
        text.setCompoundDrawablePadding(0);
        text.setPadding(10, 0, 10, 0);
      } else {
        text.setText("" + letter);
      }

      addView(text);
      setPadding(10, 0, 10, 0);

      setOnTouchListener(
          new OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent event) {
              if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
                text.setPressed(true);
                letterPressed(letter);
              }
              if (event.getActionMasked() == MotionEvent.ACTION_UP) {
                text.setPressed(false);
              }
              return false;
            }
          });

      setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    }
  private void addComment() {
    NewsdalyComment comment = new NewsdalyComment();
    DalyNews dalyNews = new DalyNews();
    cur_user = BmobUser.getCurrentUser(this, User.class);
    String getid = getIntent().getStringExtra("id");
    String user_name = cur_user.getUsername();
    TextView tx = new TextView(this);
    tx.setTextSize(15);
    tx.setPadding(5, 15, 5, 7);
    String content_c = ed_newscomment.getText().toString();
    tx.setText("用户:" + user_name + "\n" + content_c);
    dalyNews.setObjectId(getid);
    comment.setComment(content_c);
    comment.setDalyNews(dalyNews);
    comment.setCommenter(cur_user);
    comment.setCommentname(user_name);
    comment.save(
        this,
        new SaveListener() {

          @Override
          public void onSuccess() {
            // TODO Auto-generated method stub
            Toast.makeText(NewsDaylyActivity.this, "评论已添加", Toast.LENGTH_SHORT).show();
          }

          @Override
          public void onFailure(int arg0, String arg1) {
            // TODO Auto-generated method stub
            Toast.makeText(NewsDaylyActivity.this, "服务器暂未响应!", Toast.LENGTH_SHORT).show();
          }
        });

    layout_content.addView(tx);
  }
示例#20
0
 private void addTab(@NonNull List<String> tabTexts, int i) {
   final TextView tab = new TextView(getContext());
   tab.setSingleLine();
   tab.setEllipsize(TextUtils.TruncateAt.END);
   tab.setGravity(Gravity.CENTER);
   tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, menuTextSize);
   tab.setLayoutParams(new LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1.0f));
   tab.setTextColor(textUnselectedColor);
   tab.setCompoundDrawablesWithIntrinsicBounds(
       null, null, getResources().getDrawable(menuUnselectedIcon), null);
   tab.setText(tabTexts.get(i));
   tab.setPadding(dpTpPx(5), dpTpPx(12), dpTpPx(5), dpTpPx(12));
   // 添加点击事件
   tab.setOnClickListener(
       new OnClickListener() {
         @Override
         public void onClick(View v) {
           switchMenu(tab);
           if (mDropDownMenuListener != null) mDropDownMenuListener.onClickListener(v);
         }
       });
   tabMenuView.addView(tab);
   // 添加分割线
   if (i < tabTexts.size() - 1) {
     View view = new View(getContext());
     view.setLayoutParams(new LayoutParams(dpTpPx(0.5f), ViewGroup.LayoutParams.MATCH_PARENT));
     view.setBackgroundColor(dividerColor);
     tabMenuView.addView(view);
   }
 }
示例#21
0
  public VerticalCardView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray a =
        context
            .getTheme()
            .obtainStyledAttributes(attrs, R.styleable.com_gabm_fancyplaces_VerticalCardView, 0, 0);

    try {
      title = a.getString(R.styleable.com_gabm_fancyplaces_VerticalCardView_card_title);
    } finally {
      a.recycle();
    }

    // own settings
    this.setOrientation(VERTICAL);
    this.setPadding(30, 30, 30, 30);

    // text view as title
    TextView textView = new TextView(context);
    textView.setText(title);
    textView.setTextAppearance(context, R.style.TextAppearance_AppCompat_Large);
    textView.setTypeface(null, Typeface.BOLD);
    textView.setPadding(0, 20, 0, 10);
    this.addView(textView);
  }
    @Override
    public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      if (container == null) {
        // We have different layouts, and in one of them this
        // fragment's containing frame doesn't exist.  The fragment
        // may still be created from its saved state, but there is
        // no reason to try to create its view hierarchy because it
        // won't be displayed.  Note this is not needed -- we could
        // just run the code below, where we would create and return
        // the view hierarchy; it would just never be used.
        return null;
      }

      ScrollView scroller = new ScrollView(getActivity());
      TextView text = new TextView(getActivity());
      int padding =
          (int)
              TypedValue.applyDimension(
                  TypedValue.COMPLEX_UNIT_DIP, 4, getActivity().getResources().getDisplayMetrics());
      text.setPadding(padding, padding, padding, padding);
      scroller.addView(text);
      text.setText(Shakespeare.DIALOGUE[getShownIndex()]);
      return scroller;
    }
示例#23
0
  @SuppressWarnings("deprecation")
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    TextView view;
    if (convertView == null) {
      view = (TextView) LayoutInflater.from(mContext).inflate(R.layout.choose_item, parent, false);
    } else {
      view = (TextView) convertView;
    }
    view.setTag(position);
    String mString = "";
    if (mListData != null) {
      if (position < mListData.size()) {
        mString = mListData.get(position).getName();
      }
    }
    if (mString.contains("不限")) view.setText("不限");
    else view.setText(mString);
    view.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);

    if (selectedText != null && selectedText.equals(mString)) {
      view.setBackgroundDrawable(selectedDrawble); // 设置选中的背景图
    } else {
      view.setBackgroundDrawable(mContext.getResources().getDrawable(normalDrawbleId));
    }
    view.setPadding(20, 0, 0, 0);
    view.setOnClickListener(onClickListener);
    return view;
  }
示例#24
0
 private View buildLabel(String s, int pad, float size) {
   TextView result = new TextView(context);
   result.setPadding(pad, 0, 10, 10);
   result.setTextSize(size);
   result.setText(s);
   return (result);
 }
示例#25
0
  public DownloadIconsDialog(final Context context, final boolean changeSettings) {
    super(context);
    mChangeSettingsEnabled = changeSettings;

    setTitle(R.string.msg_download_icons_dialog_title);
    setCancelable(true);
    setIcon(android.R.drawable.ic_dialog_info);

    final TextView message = new TextView(context);
    String str;
    try {
      str = FileUtil.writeToString(context.getResources().openRawResource(R.raw.icons_pack));
    } catch (Exception e) {
      str = e.toString();
    }
    final SpannableString s = new SpannableString(Html.fromHtml(str));
    Linkify.addLinks(s, Linkify.WEB_URLS);
    message.setText(s);
    message.setMovementMethod(LinkMovementMethod.getInstance());
    message.setPadding(5, 5, 5, 5);
    message.setTextColor(context.getResources().getColorStateList(R.color.dialog_text_color));
    message.setLinkTextColor(context.getResources().getColorStateList(R.color.links_color));
    setView(message);

    setButton(AlertDialog.BUTTON_POSITIVE, context.getText(android.R.string.yes), this);
    setButton(AlertDialog.BUTTON_NEGATIVE, context.getText(android.R.string.no), this);
    setOnCancelListener(this);
  }
示例#26
0
  public List<TextView> buildSpannable(List<Tag> tags) {
    List<TextView> views = new ArrayList<TextView>();
    for (Tag g : tags) {
      TextView view = new TextView(getContext());
      view.setText("#" + g.content);
      view.setTag(g);
      MarginLayoutParams params =
          new MarginLayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      final int margin = U.dp2px(4);
      params.setMargins(margin * 2, margin, margin * 2, margin);
      view.setLayoutParams(params);

      view.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              FeedsSearchActivity.start(getContext(), ((Tag) v.getTag()).content);
            }
          });

      final int padding = U.dp2px(8);
      view.setPadding(padding * 2, padding, padding * 2, padding);

      view.setBackgroundDrawable(
          new RoundRectDrawable(
              U.dp2px(4),
              getContext().getResources().getColorStateList(R.color.apptheme_primary_white_btn)));
      views.add(view);
    }
    return views;
  }
    // Override QuestionWidget's add question text. Build it the same
    // but add it to the questionLayout
    protected void addQuestionText(FormEntryPrompt p) {

        // Add the text view. Textview always exists, regardless of whether there's text.
    	TextView questionText = new TextView(getContext());
        questionText.setText(p.getLongText());
        questionText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mQuestionFontsize);
        questionText.setTypeface(null, Typeface.BOLD);
        questionText.setPadding(0, 0, 0, 7);
        questionText.setId(QuestionWidget.newUniqueId()); // assign random id

        // Wrap to the size of the parent view
        questionText.setHorizontallyScrolling(false);

        if (p.getLongText() == null) {
            questionText.setVisibility(GONE);
        }

        // Put the question text on the left half of the screen
        LinearLayout.LayoutParams labelParams =
            new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
        labelParams.weight = 1;

        questionLayout = new LinearLayout(getContext());
        questionLayout.setOrientation(LinearLayout.HORIZONTAL);

        questionLayout.addView(questionText, labelParams);
    }
示例#28
0
  /**
   * 生成MyViewGroup的子元素
   *
   * @param text
   */
  private void createView1(String text, String number) {

    if (etMess.getText().toString().equals(" ") || etMess.getText().toString().equals("")) {
    } else {
      TextView t = new TextView(this);
      t.setText(text);
      t.setTextColor(Color.BLACK);
      t.setGravity(Gravity.CENTER);
      t.setBackgroundResource(R.drawable.bg_sms_contact_btn);
      t.setHeight(60);
      t.setPadding(2, 0, 2, 0);
      t.setOnClickListener(new MyListener());
      t.setTag(number);
      mvg.addView(t, mvg.getChildCount() - 1);

      ContactBean cb = new ContactBean();
      cb.setDisplayName(text);
      cb.setPhoneNum(number);
      if (null == selectContactList) {
        selectContactList = new ArrayList<ContactBean>();
      }
      selectContactList.add(cb);
      queryListView.setVisibility(View.INVISIBLE);
    }
  }
示例#29
0
  /**
   * Create a default view to be used for tabs. This is called if a custom tab view is not set via
   * {@link #setCustomTabView(int, int)}.
   */
  @SuppressLint("NewApi")
  protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      // If we're running on Honeycomb or newer, then we can use the Theme's
      // selectableItemBackground to ensure that the View has a pressed state
      TypedValue outValue = new TypedValue();
      getContext()
          .getTheme()
          .resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
      textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
      textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
  }
示例#30
0
    public PRTHeader(Context context) {
      super(context);
      setOrientation(VERTICAL);

      LinearLayout llInner = new LinearLayout(context);
      LinearLayout.LayoutParams lpInner =
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      lpInner.gravity = Gravity.CENTER_HORIZONTAL;
      addView(llInner, lpInner);

      ivArrow = new RotateImageView(context);
      int resId = getBitmapRes(context, "ssdk_oks_ptr_ptr");
      if (resId > 0) {
        ivArrow.setImageResource(resId);
      }
      int dp_32 = dipToPx(context, 32);
      LayoutParams lpIv = new LayoutParams(dp_32, dp_32);
      lpIv.gravity = Gravity.CENTER_VERTICAL;
      llInner.addView(ivArrow, lpIv);

      pbRefreshing = new ProgressBar(context);
      llInner.addView(pbRefreshing, lpIv);
      pbRefreshing.setVisibility(View.GONE);

      tvHeader = new TextView(getContext());
      tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
      tvHeader.setGravity(Gravity.CENTER);
      int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 10);
      tvHeader.setPadding(dp_10, dp_10, dp_10, dp_10);
      tvHeader.setTextColor(0xff000000);
      LayoutParams lpTv = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      lpTv.gravity = Gravity.CENTER_VERTICAL;
      llInner.addView(tvHeader, lpTv);
    }