@Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.downloaded_cancel:
        mLinearLayout.setVisibility(View.GONE);
        mLinearLayout.setPadding(0, 0, 0, 0);
        isEditor = false;
        adapter.setEditorState(isEditor);
        break;
      case R.id.downloaded_sure:
        mLinearLayout.setVisibility(View.GONE);
        mLinearLayout.setPadding(0, 0, 0, 0);
        // Integer[] deletePositions = delList.toArray(new Integer[delList
        // .size()]);
        //
        // Log.i("DownloadedFragment", "删除位置的集合:"+str);
        delLocalFile(delList);
        isEditor = false;
        adapter.setEditorState(isEditor);
        break;

      default:
        break;
    }
  }
  // 当状态改变时候,调用该方法,以更新界面
  private void changeHeaderViewByState() {
    switch (state) {
      case RELEASE_To_REFRESH:
        arrowImageView.setVisibility(View.VISIBLE);
        progressBar.setVisibility(View.GONE);
        tipsTextview.setVisibility(View.VISIBLE);
        lastUpdatedTextView.setVisibility(View.VISIBLE);

        arrowImageView.clearAnimation();
        arrowImageView.startAnimation(animation);

        tipsTextview.setText("松开刷新");

        // Log.v(TAG, "当前状态,松开刷新");
        break;
      case PULL_To_REFRESH:
        progressBar.setVisibility(View.GONE);
        tipsTextview.setVisibility(View.VISIBLE);
        lastUpdatedTextView.setVisibility(View.VISIBLE);
        arrowImageView.clearAnimation();
        arrowImageView.setVisibility(View.VISIBLE);
        // 是由RELEASE_To_REFRESH状态转变来的
        if (isBack) {
          isBack = false;
          arrowImageView.clearAnimation();
          arrowImageView.startAnimation(reverseAnimation);

          tipsTextview.setText("下拉刷新");
        } else {
          tipsTextview.setText("下拉刷新");
        }
        // Log.v(TAG, "当前状态,下拉刷新");
        break;

      case REFRESHING:
        headView.setPadding(0, 0, 0, 0);
        headView.invalidate();

        progressBar.setVisibility(View.VISIBLE);
        arrowImageView.clearAnimation();
        arrowImageView.setVisibility(View.GONE);
        tipsTextview.setText("正在刷新...");
        lastUpdatedTextView.setVisibility(View.VISIBLE);

        // Log.v(TAG, "当前状态,正在刷新...");
        break;
      case DONE:
        headView.setPadding(0, -1 * headContentHeight, 0, 0);
        headView.invalidate();

        progressBar.setVisibility(View.GONE);
        arrowImageView.clearAnimation();
        arrowImageView.setImageResource(R.drawable.xlistview_arrow);
        tipsTextview.setText("下拉刷新");
        lastUpdatedTextView.setVisibility(View.VISIBLE);

        // Log.v(TAG, "当前状态,done");
        break;
    }
  }
  private LinearLayout getTriggerStatuslayout(Trigger trigger) {
    LinearLayout triggerStatusLayout = new LinearLayout(ctx);
    triggerStatusLayout.setLayoutParams(
        new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    triggerStatusLayout.setGravity(Gravity.CENTER);
    triggerStatusLayout.setOrientation(VERTICAL);

    ImageView triggerAckImg = new ImageView(ctx);
    triggerAckImg.setImageResource(trigger.getAckImg());
    triggerAckImg.setLayoutParams(
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    triggerAckImg.setPadding(0, 5, 0, 0);

    ImageView triggerStatusImage = new ImageView(ctx);
    triggerStatusImage.setImageResource(trigger.getActiveImg());
    triggerStatusImage.setLayoutParams(
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    triggerStatusLayout.addView(triggerStatusImage);
    if (!showask()) {
      triggerStatusLayout.addView(triggerAckImg);
      // triggerStatusLayout.setGravity(Gravity.RIGHT);
      triggerStatusLayout.setPadding(0, 10, 0, 0);
    } else {
      // triggerStatusLayout.setGravity(Gravity.RIGHT);
      triggerStatusLayout.setPadding(0, 20, 0, 10);
    }

    return triggerStatusLayout;
  }
Beispiel #4
0
        public void handleMessage(android.os.Message msg) {
          switch (msg.what) {
            case REFRESH_BACKING: // 反弹中
              mHeaderLinearLayout.setPadding(
                  mHeaderLinearLayout.getPaddingLeft(),
                  (int) (mHeaderLinearLayout.getPaddingTop() * 0.75f),
                  mHeaderLinearLayout.getPaddingRight(),
                  mHeaderLinearLayout.getPaddingBottom());
              showProgressBar();
              break;

            case REFRESH_BACED: // 达到刷新界限,反弹结束后,加载数据
              headerInfo.setText("正在加载...");
              rotateArrow(ROTATE_DOWN);
              showProgressBar();
              mPullRefreshState = EXIT_PULL_REFRESH;
              new Thread() {
                public void run() {
                  if (mRefreshListener != null) {
                    mRefreshObject = mRefreshListener.refreshing();
                  }
                  Message msg = mHandler.obtainMessage();
                  msg.what = REFRESH_DONE;
                  msg.sendToTarget();
                };
              }.start();
              break;

            case REFRESH_RETURN: // 没有达到刷新界限,返回
              headerInfo.setText("下拉刷新");
              rotateArrow(ROTATE_DOWN);
              showArrow();
              mHeaderLinearLayout.setPadding(
                  mHeaderLinearLayout.getPaddingLeft(),
                  0,
                  mHeaderLinearLayout.getPaddingRight(),
                  mHeaderLinearLayout.getPaddingBottom());
              mPullRefreshState = NONE_PULL_REFRESH;
              setSelection(1);
              break;

            case REFRESH_DONE: // 加载数据结束
              headerInfo.setText("下拉刷新");
              headerTime.setText("更新时间为: " + mSimpleDateFormat.format(new Date()));
              rotateArrow(ROTATE_DOWN);
              showArrow();
              mHeaderLinearLayout.setPadding(
                  mHeaderLinearLayout.getPaddingLeft(),
                  0,
                  mHeaderLinearLayout.getPaddingRight(),
                  mHeaderLinearLayout.getPaddingBottom());
              mPullRefreshState = NONE_PULL_REFRESH;
              setSelection(1);
              if (mRefreshListener != null) {
                mRefreshListener.refreshed(mRefreshObject);
              }
              break;
          }
        };
  private void changeHeaderViewByState() {
    switch (state) {
      case RELEASE_To_REFRESH:
        arrowImageView.setVisibility(View.VISIBLE);
        progressBar.setVisibility(View.GONE);
        tipsTextview.setVisibility(View.VISIBLE);
        lastUpdatedTextView.setVisibility(View.VISIBLE);

        arrowImageView.clearAnimation();
        arrowImageView.startAnimation(animation);

        tipsTextview.setText("�ɿ�ˢ��");

        break;
      case PULL_To_REFRESH:
        progressBar.setVisibility(View.GONE);
        tipsTextview.setVisibility(View.VISIBLE);
        lastUpdatedTextView.setVisibility(View.VISIBLE);
        arrowImageView.clearAnimation();
        arrowImageView.setVisibility(View.VISIBLE);
        if (isBack) {
          isBack = false;
          arrowImageView.clearAnimation();
          arrowImageView.startAnimation(reverseAnimation);

          tipsTextview.setText("����ˢ��");
        } else {
          tipsTextview.setText("����ˢ��");
        }
        break;

      case REFRESHING:
        headView.setPadding(0, 0, 0, 0);

        progressBar.setVisibility(View.VISIBLE);
        arrowImageView.clearAnimation();
        arrowImageView.setVisibility(View.GONE);
        tipsTextview.setText("����ˢ��...");
        lastUpdatedTextView.setVisibility(View.VISIBLE);

        break;
      case DONE:
        headView.setPadding(0, -1 * headContentHeight, 0, 0);

        progressBar.setVisibility(View.GONE);
        arrowImageView.clearAnimation();
        arrowImageView.setImageResource(R.drawable.z_arrow_down);
        tipsTextview.setText("����ˢ��");
        lastUpdatedTextView.setVisibility(View.VISIBLE);

        break;
    }
  }
  // 当状态改变时候,调用该方法,以更新界面
  private void changeHeaderViewByState() {
    switch (state) {
      case RELEASE_To_REFRESH:
        lvHeaderArrowIv.setVisibility(View.VISIBLE);
        lvHeaderProgressBar.setVisibility(View.GONE);
        lvHeaderTipsTv.setVisibility(View.VISIBLE);
        lvHeaderLastUpdatedTv.setVisibility(View.VISIBLE);

        lvHeaderArrowIv.clearAnimation(); // 清除动画
        lvHeaderArrowIv.startAnimation(animation); // 开始动画效果

        lvHeaderTipsTv.setText("松开刷新");
        break;
      case PULL_To_REFRESH:
        lvHeaderProgressBar.setVisibility(View.GONE);
        lvHeaderTipsTv.setVisibility(View.VISIBLE);
        lvHeaderLastUpdatedTv.setVisibility(View.VISIBLE);
        lvHeaderArrowIv.clearAnimation();
        lvHeaderArrowIv.setVisibility(View.VISIBLE);
        // 是由RELEASE_To_REFRESH状态转变来的
        if (isBack) {
          isBack = false;
          lvHeaderArrowIv.clearAnimation();
          lvHeaderArrowIv.startAnimation(reverseAnimation);

          lvHeaderTipsTv.setText("下拉刷新");
        } else {
          lvHeaderTipsTv.setText("下拉刷新");
        }
        break;

      case REFRESHING:
        headerView.setPadding(0, 0, 0, 0);

        lvHeaderProgressBar.setVisibility(View.VISIBLE);
        lvHeaderArrowIv.clearAnimation();
        lvHeaderArrowIv.setVisibility(View.GONE);
        lvHeaderTipsTv.setText("正在刷新...");
        lvHeaderLastUpdatedTv.setVisibility(View.VISIBLE);
        break;
      case DONE:
        headerView.setPadding(0, -1 * headerContentHeight, 0, 0);

        lvHeaderProgressBar.setVisibility(View.GONE);
        lvHeaderArrowIv.clearAnimation();
        lvHeaderArrowIv.setImageResource(R.drawable.arrow);
        lvHeaderTipsTv.setText("下拉刷新");
        lvHeaderLastUpdatedTv.setVisibility(View.VISIBLE);
        break;
    }
  }
 @Override
 public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
   sparseBooleanArray.put((Integer) compoundButton.getTag(), b);
   LinearLayout ll = (LinearLayout) compoundButton.getParent();
   int[] diems = getDims(ll);
   if (b) {
     this.callback.itemSelected(sparseBooleanArray);
     ll.setBackgroundDrawable(
         context.getResources().getDrawable(R.drawable.list_pressed_holo_light));
     ll.setPadding(diems[0], diems[1], diems[2], diems[3]);
   } else {
     this.callback.itemDeSelected(sparseBooleanArray);
     ll.setBackgroundDrawable(null);
     ll.setPadding(diems[0], diems[1], diems[2], diems[3]);
   }
 }
    private LinearLayout getView(int position, Context context) {
      LinearLayout ll = new LinearLayout(context);
      ll.setOrientation(LinearLayout.VERTICAL);
      int dp_5 = cn.sharesdk.framework.utils.R.dipToPx(context, 5);
      ll.setPadding(dp_5, dp_5, dp_5, dp_5);

      ImageView iv = new ImageView(context);
      iv.setScaleType(ScaleType.CENTER_INSIDE);
      LinearLayout.LayoutParams lpIv = new LinearLayout.LayoutParams(iconWidth, iconWidth);
      lpIv.gravity = Gravity.CENTER_HORIZONTAL;
      iv.setLayoutParams(lpIv);
      iv.setImageBitmap(getIcon(platforms[position]));
      ll.addView(iv);

      TextView tv = new TextView(context);
      tv.setTextColor(0xffffffff);
      tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
      tv.setSingleLine();
      tv.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP);
      LinearLayout.LayoutParams lpTv =
          new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
      lpTv.weight = 1;
      tv.setLayoutParams(lpTv);
      tv.setText(getName(platforms[position]));
      ll.addView(tv);

      return ll;
    }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    self = this;

    Intent startingIntent = getIntent();
    isMaster = startingIntent.getBooleanExtra("isMaster", false);

    int pos = MultiScreenVideoView.POSITION_LEFT;
    if (!isMaster) {
      pos = MultiScreenVideoView.POSITION_RIGHT;
    }

    mVideo = new MultiScreenVideoView(this, pos);
    mVideo.setVideoPath("/sdcard/android.mp4");

    LinearLayout mLinearLayout = new LinearLayout(this);
    if (!isMaster) {
      mLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
      mLinearLayout.setGravity(Gravity.RIGHT);
      mLinearLayout.setPadding(0, 0, 120, 0);
    }
    mLinearLayout.addView(mVideo);

    setContentView(mLinearLayout);

    mConnection = new Connection(this, serviceReadyListener);
  }
 private LinearLayout getLL(Course course) {
   LinearLayout LL = new LinearLayout(getActivity());
   int padding = (int) (8 * getResources().getDisplayMetrics().density + 0.5F);
   LL.setPadding(padding, padding, padding, padding);
   LinearLayout.LayoutParams parameters =
       new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
   LL.setOrientation(LinearLayout.HORIZONTAL);
   LL.setLayoutParams(parameters);
   TextView courseName = new TextView(getActivity());
   LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1);
   courseName.setLayoutParams(params);
   courseName.setGravity(Gravity.LEFT);
   courseName.setText(course.getCode());
   LL.addView(courseName);
   TextView grade = new TextView(getActivity());
   grade.setTextColor(0xFFB40404);
   if (course.getPercentage() == -1) grade.setText("--%");
   else {
     DecimalFormat formatter = new DecimalFormat("0.#");
     grade.setText(formatter.format(course.getPercentage()) + "%");
   }
   LL.addView(grade);
   grade.setGravity(Gravity.RIGHT);
   return LL;
 }
Beispiel #11
0
  private void changeHeaderByState(int state) {
    switch (state) {
      case DONE:
        headerView.setPadding(0, -headerViewHeight, 0, 0);
        firstSetpView.setVisibility(View.VISIBLE);
        secondAnimation.stop();
        secondStepView.setVisibility(View.GONE);
        break;
      case RELEASE_TO_REFRESH:
        tv_pull_to_refresh.setText("松开刷新");

        break;
      case PULL_TO_REFRESH:
        tv_pull_to_refresh.setText("下拉刷新");
        state = DONE;
        firstSetpView.setVisibility(View.VISIBLE);
        secondAnimation.stop();
        secondStepView.setVisibility(View.GONE);
        break;
      case REFRESHING:
        tv_pull_to_refresh.setText("正在刷新");
        firstSetpView.setVisibility(View.GONE);
        secondStepView.setVisibility(View.VISIBLE);
        secondAnimation.stop();
        secondAnimation.start();
        break;
      default:
        break;
    }
  }
Beispiel #12
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);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    OnColorChangedListener l =
        new OnColorChangedListener() {
          public void colorChanged(int color) {
            mListener.colorChanged(color);
            dismiss();
          }
        };

    LinearLayout mainPanel = new LinearLayout(getContext());
    mainPanel.setLayoutParams(
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    mainPanel.setOrientation(LinearLayout.VERTICAL);
    mainPanel.setPadding(0, 20, 0, 20);
    mainPanel.setGravity(Gravity.CENTER);
    mainPanel.addView(new ColorPickerView(getContext(), l, mInitialColor));

    // Button cancelButton = new Button(getContext());
    // cancelButton.setText(getContext().getString(R.string.button_cancel));
    // cancelButton.setOnClickListener(new View.OnClickListener() {
    // @Override
    // public void onClick(View v) {
    // dismiss();
    // }
    // });
    // LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
    // LayoutParams.MATCH_PARENT);
    // layoutParams.setMargins(0, 40, 0, 0);
    // mainPanel.addView(cancelButton, layoutParams);

    setContentView(mainPanel);
    setTitle(getContext().getString(R.string.title_change_homestead_colour));
  }
  public SplashDialog(Context context) {
    super(context);

    scale = getContext().getResources().getDisplayMetrics().density;

    dialogView = new LinearLayout(getContext());
    dialogView.setOrientation(LinearLayout.VERTICAL);

    int padding = Utils.dpToPx(context, 2);
    dialogView.setPadding(padding, padding, padding, padding);

    int margin = Utils.dpToPx(context, 10);
    this.setPadding(margin, margin, margin, margin);

    this.setOnKeyListener(
        new OnKeyListener() {
          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            return false;
          }
        });

    addView(
        dialogView,
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
  }
  @Override
  protected void onPrepareDialogBuilder(Builder builder) {
    super.onPrepareDialogBuilder(builder);
    OnColorChangedListener l =
        new OnColorChangedListener() {
          public void colorChanged(int color) {
            mCurrentColor = color;
            onDialogClosed(true);
            getDialog().dismiss();
          }
        };

    LinearLayout layout = new LinearLayout(getContext());
    layout.setPadding(20, 20, 20, 20);
    layout.setOrientation(LinearLayout.VERTICAL);
    mCPView = new ColorPickerView(getContext(), l, mCurrentColor);

    LinearLayout.LayoutParams params1 =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    params1.gravity = Gravity.CENTER;
    mCPView.setLayoutParams(params1);
    layout.addView(this.mCPView);
    layout.setId(android.R.id.widget_frame);
    builder.setView(layout);
  }
  @Override
  protected View onCreateView(ViewGroup parent) {

    LinearLayout layout = new LinearLayout(getContext());
    LinearLayout.LayoutParams params1 =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    // params1.gravity = Gravity.LEFT;
    params1.weight = 1.0f;
    layout.setPadding(15, 10, 10, 10);
    layout.setOrientation(LinearLayout.HORIZONTAL);
    TextView view = new TextView(getContext());
    view.setText(R.string.rerun_setup_wizard);
    // view.setTextSize(18);
    // view.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
    view.setTextAppearance(getContext(), android.R.style.TextAppearance_Large);
    // view.setGravity(Gravity.LEFT);
    view.setLayoutParams(params1);

    this.setOnPreferenceClickListener(
        new OnPreferenceClickListener() {
          public boolean onPreferenceClick(Preference arg0) {
            getContext().startActivity(new Intent(getContext(), WizardActivity.class));
            return true;
          }
        });

    layout.addView(view);
    layout.setId(android.R.id.widget_frame);
    return layout;
  }
Beispiel #17
0
  private void dialogie(String s) {
    if (s == null || s.length() == 0) return;

    AlertDialog ad = new AlertDialog.Builder(me).create();
    ad.setCancelable(true);
    ad.setCanceledOnTouchOutside(true);
    ad.setTitle("Linkification view");

    LinearLayout rl = new LinearLayout(me);
    rl.setBackgroundColor(Color.WHITE);
    rl.setPadding(scalemex(5), scalemex(25), scalemex(5), scalemex(25));

    TextView tv;

    tv = new TextView(me);
    rl.addView(tv);
    tv.setBackgroundColor(Color.WHITE);
    tv.setTextColor(Color.BLACK);
    tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 19f);
    tv.setText(s);
    Linkify.addLinks(tv, Linkify.ALL);

    ScrollView ho = new ScrollView(me);
    ho.addView(rl);

    ad.setView(ho);
    ad.show();
  }
    private void init(Context context, int color) {

      // To fight color branding.
      getWindow().setFormat(PixelFormat.RGBA_8888);

      final LinearLayout mContentView = new LinearLayout(context);
      mContentView.setGravity(Gravity.CENTER);

      mColorPicker = new ColorPickerView(context);

      mContentView.addView(mColorPicker, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

      mContentView.setPadding(
          Math.round(mColorPicker.getDrawingOffset()),
          0,
          Math.round(mColorPicker.getDrawingOffset()),
          0);

      mColorPicker.setOnColorChangedListener(this);
      mColorPicker.setColor(color, true);
      mColorPicker.setAlphaSliderVisible(true);

      setTitle(R.string.pick_color);
      setView(mContentView);

      setButton(BUTTON_POSITIVE, context.getString(android.R.string.ok), this);
      setButton(BUTTON_NEGATIVE, context.getString(android.R.string.cancel), this);
    }
  /**
   * creates a linear layout the contains only a textview. (non-Javadoc)
   *
   * @see android.preference.Preference#onCreateView(android.view.ViewGroup)
   * @param parent
   * @return
   * @author ricky barrette
   */
  @Override
  protected View onCreateView(final ViewGroup parent) {

    /*
     * create a vertical linear layout that width and height that wraps
     * content
     */
    final LinearLayout layout = new LinearLayout(getContext());
    final LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.CENTER;
    layout.setPadding(15, 5, 10, 5);
    layout.setOrientation(LinearLayout.VERTICAL);

    layout.removeAllViews();

    /*
     * create a textview that will be used to display the title provided in
     * xml and add it to the lay out
     */
    final TextView title = new TextView(getContext());
    title.setText(getTitle());
    title.setTextSize(16);
    title.setTypeface(Typeface.SANS_SERIF);
    title.setGravity(Gravity.LEFT);
    title.setLayoutParams(params);

    /*
     * add the title and the time picker views to the layout
     */
    layout.addView(title);
    layout.setId(android.R.id.widget_frame);

    return layout;
  }
  public LinearLayout crearImagen(Bitmap bitmap, final int nIdFoto) {
    ImageView ivImagen = new ImageView(this);

    LinearLayout linear_contenedorRegistro = (LinearLayout) new LinearLayout(this);
    linear_contenedorRegistro.setOrientation(LinearLayout.HORIZONTAL);
    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    lp.setMargins(0, 0, 0, 0);
    lp.weight = 1;
    linear_contenedorRegistro.setLayoutParams(lp);
    linear_contenedorRegistro.setPadding(2, 2, 2, 2);

    if (bitmap != null) {
      // android:adjustViewBounds
      ivImagen.setImageBitmap(RotateBitmap(bitmap, 90));
      ivImagen.setAdjustViewBounds(true);

      ivImagen.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
              // TODO Auto-generated method stub
              irPreview(nIdFoto);
            }
          });
    }

    linear_contenedorRegistro.addView(ivImagen);

    return linear_contenedorRegistro;
  }
Beispiel #21
0
 public void bindSectionHeader(View view, int position, boolean displaySectionHeader) {
   TextView tv = (TextView) view.findViewById(R.id.information_header);
   LinearLayout layoutOther = (LinearLayout) view.findViewById(R.id.information_layout_other);
   if (topPadding == 0) {
     topPadding = layoutOther.getPaddingTop();
   }
   LinearLayout layoutTitle = (LinearLayout) view.findViewById(R.id.information_layout_title);
   if (displaySectionHeader) {
     layoutTitle.setVisibility(View.VISIBLE);
     tv.setText(getSections()[getSectionForPosition(position)]);
     layoutOther.setPadding(0, topPadding, 0, 0);
   } else {
     layoutTitle.setVisibility(View.GONE);
     layoutOther.setPadding(0, 0, 0, 0);
   }
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String response = getIntent().getStringExtra("response");
    boolean success = getIntent().getBooleanExtra("success", false);

    LinearLayout l = new LinearLayout(this);
    l.setOrientation(LinearLayout.VERTICAL);
    l.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    l.setPadding(10, 10, 10, 10);

    TextView t = new TextView(this);
    t.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    t.setGravity(Gravity.CENTER);
    if (success) {
      t.setText(R.string.sync_ok);
    } else {
      t.setText(R.string.sync_failed);
    }
    t.setTextSize(22);
    l.addView(t);
    t = new TextView(this);
    t.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    t.setText(response);
    l.addView(t);
    setContentView(l);
  }
  @Override
  public View getView(Context context) {

    l = new LinearLayout(context);

    LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);

    l.setLayoutParams(params);

    b = new ImageButton(context);
    b.setLayoutParams(params);
    b.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            ImageButtonModifier.this.onClick();
          }
        });
    b.setImageResource(myText);

    if (getTheme() != null) getTheme().applyNormal1(b);

    int p = 6;
    b.setPadding(p, p, p, p);

    l.addView(b);
    int p2 = 2;
    l.setPadding(p2, p2, p2, p2);

    return l;
  }
Beispiel #24
0
 public CustomDialog(Context context) {
   super(context);
   items = new ArrayList<>();
   icon = getContext().getResources().getDimensionPixelSize(R.dimen.dimen_32_dp);
   padding = getContext().getResources().getDimensionPixelSize(R.dimen.dimen_8_dp);
   ViewGroup.LayoutParams params =
       new ViewGroup.LayoutParams(
           ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
   container = new LinearLayout(getContext());
   container.setLayoutParams(params);
   container.setBackgroundColor(Color.WHITE);
   container.setOrientation(LinearLayout.VERTICAL);
   container.setPadding(0, padding, 0, padding);
   ScrollView scrollView = new ScrollView(getContext());
   scrollView.addView(container);
   requestWindowFeature(Window.FEATURE_NO_TITLE);
   setContentView(scrollView, params);
   setCancelable(true);
   setCanceledOnTouchOutside(true);
   getWindow().setGravity(Gravity.BOTTOM);
   getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
   getWindow()
       .setLayout(
           WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
   getWindow().getAttributes().windowAnimations = R.style.DialogAnimation;
 }
  @Override
  protected View onCreateDialogView() {
    LinearLayout.LayoutParams params;
    LinearLayout layout = new LinearLayout(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPadding(6, 6, 6, 6);

    final TextView splashText = new TextView(mContext);
    if (mDialogMessage != null) splashText.setText(mDialogMessage);
    layout.addView(splashText);

    mValueText = new TextView(mContext);
    mValueText.setGravity(Gravity.CENTER_HORIZONTAL);
    mValueText.setTextSize(32);
    params =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    layout.addView(mValueText, params);

    mSeekBar = new SeekBar(mContext);
    mSeekBar.setOnSeekBarChangeListener(this);
    layout.addView(
        mSeekBar,
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));

    if (shouldPersist()) mValue = getPersistedInt(mDefault);

    mSeekBar.setMax(mMax);
    mSeekBar.setProgress(mValue);
    return layout;
  }
Beispiel #26
0
  // 录音时间太短时Toast显示
  void showWarnToast(String toastText) {
    Toast toast = new Toast(ChatActivity.this);
    LinearLayout linearLayout = new LinearLayout(ChatActivity.this);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setPadding(20, 20, 20, 20);

    // 定义一个ImageView
    ImageView imageView = new ImageView(ChatActivity.this);
    imageView.setImageResource(R.mipmap.voice_to_short); // 图标

    TextView mTv = new TextView(ChatActivity.this);
    mTv.setText(toastText);
    mTv.setTextSize(14);
    mTv.setTextColor(Color.WHITE); // 字体颜色

    // 将ImageView和ToastView合并到Layout中
    linearLayout.addView(imageView);
    linearLayout.addView(mTv);
    linearLayout.setGravity(Gravity.CENTER); // 内容居中
    linearLayout.setBackgroundResource(R.mipmap.record_bg); // 设置自定义toast的背景

    toast.setView(linearLayout);
    toast.setGravity(Gravity.CENTER, 0, 0); // 起点位置为中间
    toast.show();
  }
  @Override
  protected View onCreateDialogView() {
    LinearLayout.LayoutParams params;
    LinearLayout layout = new LinearLayout(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPadding(6, 6, 6, 6);

    mValueText = new TextView(mContext);
    mValueText.setGravity(Gravity.CENTER_HORIZONTAL);
    mValueText.setTextSize(32);
    params =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    layout.addView(mValueText, params);

    mSeekBar = new SeekBar(mContext);
    mSeekBar.setOnSeekBarChangeListener(this);

    layout.addView(
        mSeekBar,
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));

    if (shouldPersist()) {
      mValue = getPersistedInt(mDefault);
    }

    mSeekBar.setMax((int) ((mMax - mMin) / mInterval));
    mSeekBar.setProgress((int) ((mValue - mMin) / mInterval));

    String t = String.valueOf(mValue);
    mValueText.setText(mSuffix == null ? t : t.concat(mSuffix));
    return layout;
  }
Beispiel #28
0
  private LinearLayout getTitleView(Context context, AlertType type) {
    this.context = context;

    LinearLayout mainLine = new LinearLayout(context);
    mainLine.setOrientation(LinearLayout.HORIZONTAL);
    LayoutParams layoutParams =
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    mainLine.setLayoutParams(layoutParams);
    mainLine.setPadding(
        Tool.dip2px(context, 10),
        Tool.dip2px(context, 10),
        Tool.dip2px(context, 10),
        Tool.dip2px(context, 10));
    mainLine.setGravity(Gravity.CENTER_VERTICAL);

    mainLine.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.toast_background));

    ImageView imageView = new ImageView(context);
    if (type == AlertType.ERR) {
      imageView.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.err));
    } else if (type == AlertType.INFO) {
      imageView.setBackgroundDrawable(
          context.getResources().getDrawable(R.drawable.radio_bt_selected));
    } else {
      imageView.setBackgroundDrawable(null);
    }
    mainLine.addView(imageView);

    textView = new TextView(context);
    textView.setTextColor(context.getResources().getColor(R.color.white));

    textView.setTextSize(16);
    mainLine.addView(textView);
    return mainLine;
  }
  @Override
  public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    LinearLayout itemView = new LinearLayout(parent.getContext());

    TextView textView = new TextView(parent.getContext());
    textView.setTextSize(18);
    textView.setId(android.R.id.text1);

    RecyclerView.LayoutParams layoutParams =
        new RecyclerView.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, Converter.dp2px(itemView.getContext(), 56));

    itemView.setPadding(
        Converter.dp2px(itemView.getContext(), 16),
        0,
        Converter.dp2px(itemView.getContext(), 16),
        0);
    itemView.setGravity(Gravity.LEFT | Gravity.START | Gravity.CENTER);
    itemView.setBackgroundResource(R.drawable.touch_feedback_holo_light);
    itemView.addView(textView);
    itemView.setLayoutParams(layoutParams);
    if (this.layoutManager instanceof GridLayoutManager) {
      calculateGridItemSize(itemView);
    }

    return new ViewHolder(itemView);
  }
	private void init(Context context) {
		mResistance = DEFAULT_RESISTANCE;

		// Add the list and the header to the container.
		mContainer = new LinearLayout(context);
		mContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
		((LinearLayout) mContainer).setOrientation(LinearLayout.VERTICAL);
		addView(mContainer);

		mState = STATE_IDLE; // Start out as idle.

		// We don't want to see the fading edge on the container.
		setVerticalFadingEdgeEnabled(false);
		setVerticalScrollBarEnabled(false);

		// Set the default list and header.
		TextView headerView = new TextView(context);
		headerView.setText("Default refresh header.");
		int headerViewId = 15134;
		headerView.setId(headerViewId);
		LinearLayout headerContainer = new LinearLayout(context);
		headerContainer.setPadding(0, 100, 0, 0);
		headerContainer.addView(headerView);
		setRefreshHeader(headerContainer, headerViewId);
		ListView list = new ListView(context);
		setList(list);
	}