Example #1
0
  private void addPhoto(int position, LinearLayout layout, JSONArray imgs) {
    ImageView photo = new ImageView(context);
    // 设置当前图像的图像(position为当前图像列表的位置)
    photo.setScaleType(ImageView.ScaleType.CENTER_INSIDE);

    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    lp.setMargins(5, 0, 0, 0);
    photo.setLayoutParams(lp);
    // 设置Gallery组件的背景风格
    // oneHolder.photo.setVisibility(View.VISIBLE);
    if (position < imgs.length())
      try {
        ImagerLoader loader = new ImagerLoader();
        loader.LoadImage(imgs.getJSONObject(position).getString("url"), photo);

        // new DownAndShowImageTask(imgs.getJSONObject(position)
        // .getString("url"), photo).execute();
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

    layout.addView(photo);
  }
 /** 图片循环 */
 private void initViewPager() {
   ViewGroup.LayoutParams mViewPagerlayoutParams = mViewPager.getLayoutParams();
   if (mViewPagerlayoutParams != null) {
     mViewPagerlayoutParams.width = Misc.getScreenDisplay(this)[0];
     mViewPagerlayoutParams.height = (int) (mViewPagerlayoutParams.width);
     mViewPager.setLayoutParams(mViewPagerlayoutParams);
   }
   mViewPager.setAdapter(new ProductDetailPicAdapter2(this, product.getImgList()));
   mViewPager.setOnPageChangeListener(this);
   // 设置布局参数
   LinearLayout.LayoutParams params =
       new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
   int marginParam = Misc.dip2px(this, 10) / 2;
   llytPagerPoiner.removeAllViewsInLayout();
   for (int i = 0; i < product.getImgList().size(); i++) {
     // 设置按钮属性
     View item = new ImageView(this);
     item.setBackgroundResource(R.drawable.recommend_gallery);
     item.setTag(String.valueOf(i));
     // item.setOnClickListener(parentActivity);
     params.setMargins(marginParam, 0, marginParam, 0);
     params.weight = 1;
     llytPagerPoiner.addView(item, params);
   }
   llytPagerPoiner.getChildAt(0).setBackgroundResource(R.drawable.recommend_gallery_select);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    generateShuffle();

    mainLayout = (LinearLayout) findViewById(R.id.activity_main_linear_layout);
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    params.weight = 1f;
    for (int i = 0; i < 4; i++) {
      LinearLayout row = new LinearLayout(this);
      // row.setOrientation(LinearLayout.HORIZONTAL);
      for (int j = 0; j < 3; j++) {
        ImageView imageView = new ImageView(this);
        imageView.setTag(tag++);
        imageView.setOnClickListener(this);
        imageView.setImageResource(R.drawable.card_back);
        row.addView(imageView, params);
      }
      mainLayout.addView(row, params);
    }
  }
  private void loadVideo() {
    getWindow().setFormat(PixelFormat.TRANSLUCENT);
    mVideoView = (VideoView) findViewById(R.id.imageViewCenter);
    mVideoView.setMediaController(new MediaController(this));
    Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.water_drop);
    mVideoView.setVideoURI(video);
    mVideoView.start();

    if (isLEFT) {

      lp.setMargins(1200, 0, -1000, 0);
      mThumbnailTopLayout.setVisibility(View.GONE);
      mThumnailBottomLayout.setVisibility(View.GONE);

    } else {
      lp.setMargins(-640, 0, 640, 0);
    }
    mVideoView.setLayoutParams(lp);

    mVideoView.setClickable(true);
    mVideoView.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            // System.out.println(mVideoView);
            // mVideoView.stopPlayback();
            lp.setMargins(0, 0, 0, 0);
            mVideoView.setLayoutParams(lp);
            return true;
          }
        });
  }
    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;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      if (convertView == null) {
        convertView =
            LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_toc_entry, parent, false);
      }
      Section section = (Section) getItem(position);
      TextView sectionHeading = (TextView) convertView.findViewById(R.id.page_toc_item_text);
      View sectionFiller = convertView.findViewById(R.id.page_toc_filler);

      LinearLayout.LayoutParams indentLayoutParameters =
          new LinearLayout.LayoutParams(sectionFiller.getLayoutParams());
      indentLayoutParameters.width =
          (section.getLevel() - 1)
              * (int) (INDENTATION_WIDTH_DP * WikipediaApp.getInstance().getScreenDensity());
      sectionFiller.setLayoutParams(indentLayoutParameters);

      sectionHeading.setText(Html.fromHtml(section.getHeading()));

      if (section.getLevel() > 1) {
        sectionHeading.setTextColor(
            WikipediaApp.getInstance()
                .getResources()
                .getColor(getThemedAttributeId(parentActivity, R.attr.toc_subsection_text_color)));
      } else {
        sectionHeading.setTextColor(
            WikipediaApp.getInstance()
                .getResources()
                .getColor(getThemedAttributeId(parentActivity, R.attr.toc_section_text_color)));
      }
      return convertView;
    }
  public void addAvailableAddresses() {

    for (int i = 0; i < Constants.addressData.size(); i++) {

      rowView = layoutInflater.inflate(R.layout.include_available_address, null);
      LinearLayout.LayoutParams params =
          (LinearLayout.LayoutParams)
              new LinearLayout.LayoutParams(
                  LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      params.setMargins(0, 0, 0, 5);
      rowView.setLayoutParams(params);

      address = (CustomTextView) rowView.findViewById(R.id.address_text_included);
      address.setTag("address_" + i);
      address.setVisibility(View.VISIBLE);
      Log.d(
          Constants.LOG_TAG,
          " Setting the adress " + Constants.addressData.get(i).getFullAddress());
      address.setText(Constants.addressData.get(i).getFullAddress());
      address.setOnClickListener(inflatedViewListener);

      mobileNumber = (CustomTextView) rowView.findViewById(R.id.mobile_number_text_included);
      mobileNumber.setTag("number_" + i);
      mobileNumber.setVisibility(View.VISIBLE);
      Log.d(
          Constants.LOG_TAG,
          " Setting the mobile number " + Constants.addressData.get(i).getMobileNumber());
      mobileNumber.setText(Constants.addressData.get(i).getMobileNumber());
      mobileNumber.setOnClickListener(inflatedViewListener);

      selectAddressChild.addView(rowView);
    }
  }
Example #8
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ChatMessages messages = this.getItem(position);
    View row = convertView;
    ChatMessagesHolder holder = null;

    if (row == null) {
      LayoutInflater inflater = ((Activity) context).getLayoutInflater();
      row = inflater.inflate(layoutResourceId, parent, false);
      holder = new ChatMessagesHolder();
      holder.message = (TextView) row.findViewById(R.id.message_text);
      row.setTag(holder);
    } else {
      holder = (ChatMessagesHolder) row.getTag();
    }

    ChatMessages chatMessages = data[position];
    holder.message.setText(chatMessages.message);

    if (messages.IsMine()) {
      // not currently working as intended
      LinearLayout.LayoutParams lp = (LayoutParams) holder.message.getLayoutParams();
      lp.gravity = Gravity.RIGHT;
      holder.message.setLayoutParams(lp);
    } else {
    }

    return row;
  }
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.button_reply_send:
       if (!ChhApplication.getInstance().isLogin()) {
         ToastUtil.show(getActivity(), R.string.need_login);
         startActivity(LoginActivity.getStartIntent(getActivity()));
         return;
       }
       if (mQuoteReply != null) {
         quoteReply();
       } else {
         reply();
       }
     case R.id.button_smile:
       if (layoutSmile.getVisibility() == View.VISIBLE) {
         SmileyPickerUtility.showKeyBoard(editTextFastReply);
         layoutSmile.setVisibility(View.GONE);
       } else {
         int height = SmileyPickerUtility.getKeyboardHeight(getActivity());
         LinearLayout.LayoutParams params =
             (LinearLayout.LayoutParams) layoutSmile.getLayoutParams();
         params.height = height;
         layoutSmile.setVisibility(View.VISIBLE);
         SmileyPickerUtility.hideSoftInput(editTextFastReply);
       }
       break;
     default:
       break;
   }
 }
  @Override
  /**
   * Ask the host application for a custom progress view to show while a <video> is loading.
   *
   * @return View The progress view.
   */
  public View getVideoLoadingProgressView() {

    if (mVideoProgressView == null) {
      // Create a new Loading view programmatically.

      // create the linear layout
      LinearLayout layout = new LinearLayout(this.appView.getContext());
      layout.setOrientation(LinearLayout.VERTICAL);
      RelativeLayout.LayoutParams layoutParams =
          new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
      layout.setLayoutParams(layoutParams);
      // the proress bar
      ProgressBar bar = new ProgressBar(this.appView.getContext());
      LinearLayout.LayoutParams barLayoutParams =
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      barLayoutParams.gravity = Gravity.CENTER;
      bar.setLayoutParams(barLayoutParams);
      layout.addView(bar);

      mVideoProgressView = layout;
    }
    return mVideoProgressView;
  }
  @SuppressWarnings("unused")
  private void initSubFragmentProgress() {
    RelativeLayout subFragmentHolder =
        (RelativeLayout) rootView.findViewById(R.id.wizard_sub_fragments_holder);
    subFragmentHolder.setVisibility(View.VISIBLE);

    subFragmentProgress = (LinearLayout) rootView.findViewById(R.id.wizard_sub_fragments_progress);

    for (int i = 0; i < subFragmentProgress.getChildCount(); i++) {
      try {
        View v = subFragmentProgress.getChildAt(i);
        ((LinearLayout) v.getParent()).removeView(v);
      } catch (NullPointerException e) {
      }
    }

    for (Fragment f : subFragments) {
      ImageView p = new ImageView(a);
      LinearLayout.LayoutParams lp =
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      lp.setMargins(5, 0, 5, 0);
      p.setLayoutParams(lp);
      subFragmentProgress.addView(p);
    }

    subFragmentNext = (ImageButton) rootView.findViewById(R.id.wizard_sub_fragment_next);
    subFragmentNext.setOnClickListener(this);

    advanceWizardSubFragment(subFragments.get(0));
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
      if (requestCode == 1000) {
        Uri uri = data.getData();
        ContentResolver cr = getActivity().getContentResolver();
        try {
          Bitmap bitmap = BitmapFactory.decodeStream(cr.openInputStream(uri));
          ImageView ivHead = new ImageView(getActivity());
          ivHead.setImageBitmap(ImageViewUtil.centerSquareScaleBitmap(bitmap, 60));

          LinearLayout.LayoutParams lp =
              new LinearLayout.LayoutParams(
                  (int) getResources().getDimension(R.dimen.refresh_header_height),
                  (int) getResources().getDimension(R.dimen.refresh_header_height));
          lp.setMargins(5, 0, 5, 0);
          vContainer.addView(ivHead, lp);
          // TODO 命名规则??
          new GetAndUploadFile(getActivity()).resumableUpload(uri.getPath(), "user/head.jpg");
        } catch (FileNotFoundException e) {

        }
      }
    }
    super.onActivityResult(requestCode, resultCode, data);
  }
 private void initDots() {
   // TODO Auto-generated method stub
   dotList.clear();
   advll_dot.removeAllViews();
   dotPosition = -1;
   LinearLayout.LayoutParams lp =
       new LinearLayout.LayoutParams(
           ContextUtil.dip2px(PreMainActivity.this, 8),
           ContextUtil.dip2px(PreMainActivity.this, 8));
   lp.setMargins(
       ContextUtil.dip2px(PreMainActivity.this, 1.5f),
       0,
       ContextUtil.dip2px(PreMainActivity.this, 1.5f),
       0);
   int count = companies.size();
   int size = 0;
   if (count % 6 == 0) {
     size = count / 6;
   } else {
     size = count / 6 + 1;
   }
   for (int i = 0; i < size; i++) {
     ImageView iv_dot = new ImageView(PreMainActivity.this);
     iv_dot.setLayoutParams(lp);
     iv_dot.setBackgroundResource(R.drawable.app_dot_normal);
     if (i == 0) {
       iv_dot.setBackgroundResource(R.drawable.app_dot_focused);
     }
     advll_dot.addView(iv_dot);
     dotList.add(iv_dot);
   }
 }
 /** Show find dialog. Very pretty UI code ;) */
 public void showFindDialog() {
   Log.d(TAG, "find dialog...");
   final Dialog dialog = new Dialog(this);
   dialog.setTitle(R.string.find_dialog_title);
   LinearLayout contents = new LinearLayout(this);
   contents.setOrientation(LinearLayout.VERTICAL);
   this.findTextInputField = new EditText(this);
   this.findTextInputField.setWidth(this.pagesView.getWidth() * 80 / 100);
   Button goButton = new Button(this);
   goButton.setText(R.string.find_go_button);
   goButton.setOnClickListener(
       new OnClickListener() {
         public void onClick(View v) {
           String text = OpenFileActivity.this.findTextInputField.getText().toString();
           OpenFileActivity.this.findText(text);
           dialog.dismiss();
         }
       });
   LinearLayout.LayoutParams params =
       new LinearLayout.LayoutParams(
           LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
   params.leftMargin = 5;
   params.rightMargin = 5;
   params.bottomMargin = 2;
   params.topMargin = 2;
   contents.addView(findTextInputField, params);
   contents.addView(goButton, params);
   dialog.setContentView(contents);
   dialog.show();
 }
  @SuppressLint("InflateParams")
  @Override
  protected void initBody() {
    View view = mRoot.findViewById(R.id.jiaofei_company);
    initText(view, R.id.name, R.string.payment_common_jiaofei_company);
    initText(view, R.id.value, ((PaymentCommonSubmitBean) mParam).companyname);

    view = mRoot.findViewById(R.id.jiaofei_money);
    initText(view, R.id.name, R.string.payment_common_yingjiao_money);
    initText(view, R.id.value, ((PaymentCommonSubmitBean) mParam).needfare + "元");

    ViewGroup zhifu = (ViewGroup) mRoot.findViewById(R.id.zhifu_channel);
    String[] channels = getResources().getStringArray(R.array.zhifu_channel);
    int size = channels.length;
    View group;

    for (int i = 0; i < size; i++) {
      group = LayoutInflater.from(this).inflate(R.layout.payment_common_zhifu_type, null);
      initTextImage(group, R.id.select_type_value, imageIds[i], channels[i]);
      LinearLayout.LayoutParams params =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT);
      params.topMargin = 3;
      group.setId(i);
      initView(group);
      zhifu.addView(group, params);
    }
  }
  /**
   * 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;
  }
Example #17
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);
    }
Example #18
0
  @Override
  protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    if (type == Type.Centered) {
      if (maxTabWidth == Integer.MIN_VALUE) {
        for (int i = 0; i < tabWidget.getTabCount(); i++) {
          View tabView = tabWidget.getChildTabViewAt(i);
          if (tabView.getMeasuredWidth() > maxTabWidth) {
            maxTabWidth = tabView.getMeasuredWidth();
          }
        }

        if (maxTabWidth > 0) {
          for (int i = 0; i < tabWidget.getTabCount(); i++) {
            View tabView = tabWidget.getChildTabViewAt(i);
            LinearLayout.LayoutParams params =
                (LinearLayout.LayoutParams) tabView.getLayoutParams();
            params.width = maxTabWidth;
            tabView.setLayoutParams(params);
          }
        }
      }
    }

    super.onLayout(changed, left, top, right, bottom);
  }
Example #19
0
  public void addSegment(String title) {
    DisplayMetrics metrics = new DisplayMetrics();
    ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(metrics);

    ToggleButton b = new ToggleButton(getContext());
    b.setText(title);
    b.setTextOff(title);
    b.setTextOn(title);
    b.setTextColor(Color.WHITE);
    b.setTypeface(Typeface.DEFAULT_BOLD);
    b.setMinimumWidth((int) (40 * metrics.density));
    if (mSwitches.size() == 0) {
      b.setBackgroundResource(mLeftDrawable);
      b.setEnabled(false);
      b.setChecked(true);
    } else {
      if (mSwitches.size() > 1) {
        ToggleButton temp = mSwitches.get(mSwitches.size() - 1);
        temp.setBackgroundResource(mMidDrawable);
      }

      b.setBackgroundResource(mRightDrawable);
    }

    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.weight = 0.1f;
    params.gravity = Gravity.CENTER;
    b.setLayoutParams(params);

    b.setOnCheckedChangeListener(this);

    mSwitches.add(b);
    addView(b);
  }
  @SuppressLint("InflateParams")
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
      convertView = LayoutInflater.from(context).inflate(R.layout.user_item, null);
      ItemViewCache itemViewCache = new ItemViewCache();
      itemViewCache.imageViewUser = (ImageView) convertView.findViewById(R.id.imageViewUser);
      itemViewCache.textViewUser = (TextView) convertView.findViewById(R.id.textViewUser);
      itemViewCache.textViewCount = (TextView) convertView.findViewById(R.id.textViewCount);
      itemViewCache.textViewDate = (TextView) convertView.findViewById(R.id.textViewDate);
      convertView.setTag(itemViewCache);
    }

    ItemViewCache cache = (ItemViewCache) convertView.getTag();
    User user = userList.get(position);
    URL url = user.getUserAvatar();
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(128, 128);
    layoutParams.leftMargin = 5;
    layoutParams.rightMargin = 5;
    layoutParams.topMargin = 5;
    layoutParams.bottomMargin = 5;
    cache.imageViewUser.setLayoutParams(layoutParams);
    if (url != null) {
      imageLoader.displayImage(url.toString(), cache.imageViewUser);
    }

    cache.textViewUser.setText(user.getTitle());
    cache.textViewCount.setText("随笔总数:" + user.getPostCount());
    cache.textViewDate.setText("最后更新:" + AppUtils.parseDateToString(user.getUpdatedDate()));

    return convertView;
  }
Example #21
0
  private void init(Context context) {
    inflater = LayoutInflater.from(context);
    view = inflater.inflate(R.layout.cs_message_about, null);
    LinearLayout.LayoutParams param_view =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    param_view.leftMargin = DisplayManager.GetInstance().changeWidthSize(30);
    param_view.rightMargin = DisplayManager.GetInstance().changeWidthSize(30);
    param_view.topMargin = DisplayManager.GetInstance().changeWidthSize(20);
    view.setLayoutParams(param_view);
    version_title = (TextView) view.findViewById(R.id.version_title);
    version_content = (TextView) view.findViewById(R.id.version_content);
    help_title = (TextView) view.findViewById(R.id.help_title);
    help_title.setFocusable(true);
    help_title.setFocusableInTouchMode(true);
    help_content = (TextView) view.findViewById(R.id.help_content);

    version_title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, TEXT_SIZE);
    version_content.setTextSize(TypedValue.COMPLEX_UNIT_DIP, TEXT_SIZE);
    help_title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, TEXT_SIZE);
    help_content.setTextSize(TypedValue.COMPLEX_UNIT_DIP, TEXT_SIZE);

    version_title.setText("版本信息");
    version_content.setText("当前版本:" + Config.GetInstance().getVersionDisplayText());
    help_title.setText("使用帮助");
    addView(view);

    setContentData(getHelpContent(Config.OemType.getOemType(Config.GetInstance().getOemType())));
  }
  private void populateTabStrip() {
    final PagerAdapter adapter = viewPager.getAdapter();

    for (int i = 0; i < adapter.getCount(); i++) {

      final View tabView =
          (tabProvider == null)
              ? createDefaultTabView(adapter.getPageTitle(i))
              : tabProvider.createTabView(tabStrip, i, adapter);

      if (tabView == null) {
        throw new IllegalStateException("tabView is null.");
      }

      if (distributeEvenly) {
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
        lp.width = 0;
        lp.weight = 1;
      }

      if (internalTabClickListener != null) {
        tabView.setOnClickListener(internalTabClickListener);
      }

      tabStrip.addView(tabView);

      if (i == viewPager.getCurrentItem()) {
        tabView.setSelected(true);
      }
    }
  }
Example #23
0
 private void populateTabStrip() {
   final PagerAdapter adapter = mViewPager.getAdapter();
   final View.OnClickListener tabClickListener = new TabClickListener();
   for (int i = 0; i < adapter.getCount(); i++) {
     View tabView = null;
     TextView tabTitleView = null;
     if (mTabViewLayoutId != 0) {
       // If there is a custom tab view layout id set, try and inflate it
       tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
       tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
     }
     if (tabView == null) {
       tabView = createDefaultTabView(getContext());
     }
     if (tabTitleView == null && TextView.class.isInstance(tabView)) {
       tabTitleView = (TextView) tabView;
     }
     if (mDistributeEvenly) {
       LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
       lp.width = 0;
       lp.weight = 1;
     }
     tabTitleView.setText(adapter.getPageTitle(i));
     tabView.setOnClickListener(tabClickListener);
     String desc = mContentDescriptions.get(i, null);
     if (desc != null) {
       tabView.setContentDescription(desc);
     }
     mTabStrip.addView(tabView);
     if (i == mViewPager.getCurrentItem()) {
       tabView.setSelected(true);
     }
   }
 }
Example #24
0
  private LayoutParams getCurLayoutParams() {

    LinearLayout.LayoutParams layoutParams =
        new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, Tool.dip2px(getContext(), 35));
    layoutParams.topMargin = Tool.dip2px(getContext(), 1);
    return layoutParams;
  }
Example #25
0
  @Override
  public View getView(Context context) {

    View view = LayoutInflater.from(context).inflate(getCardLayout(), null);

    mCardLayout = view;

    try {
      ((FrameLayout) view.findViewById(R.id.cardContent)).addView(getCardContent(context));
    } catch (NullPointerException e) {
      e.printStackTrace();
    }

    // ((TextView) view.findViewById(R.id.title)).setText(this.title);

    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    int bottom = Utils.convertDpToPixelInt(context, 12);
    lp.setMargins(0, 0, 0, bottom);

    view.setLayoutParams(lp);

    return view;
  }
  boolean resizeCameras() {
    try {
      int screen_width = readScreenWidth(this);
      camerasPerRow = recalculateCameraPerRow();

      io.evercam.androidapp.custom.FlowLayout camsLineView =
          (io.evercam.androidapp.custom.FlowLayout) this.findViewById(R.id.cameras_flow_layout);
      for (int i = 0; i < camsLineView.getChildCount(); i++) {
        LinearLayout pview = (LinearLayout) camsLineView.getChildAt(i);
        CameraLayout cameraLayout = (CameraLayout) pview.getChildAt(0);

        LinearLayout.LayoutParams params =
            new LinearLayout.LayoutParams(
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
        params.width =
            ((i + 1 % camerasPerRow == 0)
                ? (screen_width - (i % camerasPerRow) * (screen_width / camerasPerRow))
                : screen_width / camerasPerRow);
        params.width = params.width - 1; // 1 pixels spacing between cameras
        params.height = (int) (params.width / (1.25));
        params.setMargins(1, 1, 0, 0); // 1 pixels spacing between cameras
        cameraLayout.setLayoutParams(params);
      }
      return true;
    } catch (Exception e) {
      Log.e(TAG, e.toString() + "::" + Log.getStackTraceString(e));

      sendToMint(e);

      EvercamPlayApplication.sendCaughtException(this, e);
      CustomedDialog.showUnexpectedErrorDialog(CamerasActivity.this);
    }
    return false;
  }
    // 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);
    }
  private void addTextView() {
    removeAllViews();
    if (mIndexListSize < 1) {
      return;
    }

    TextView tmpTV;
    for (double i = 1; i <= mIndexListSize; i++) {
      String tmpAlphabet = mAlphabetList.get((int) i - 1).firstAlphabet;

      tmpTV = new TextView(getContext());
      tmpTV.setText(tmpAlphabet);
      tmpTV.setGravity(Gravity.CENTER);
      tmpTV.setTextSize(TypedValue.COMPLEX_UNIT_PX, mAlphabetTextSize);
      tmpTV.setTextColor(Color.BLACK);
      LinearLayout.LayoutParams params =
          new LinearLayout.LayoutParams(
              ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
      params.leftMargin = mAlphabetLeftMargin;
      tmpTV.setLayoutParams(params);
      tmpTV.setIncludeFontPadding(false);

      addView(tmpTV);
    }
  }
  /**
   * Updates the View State when the mode has been set. This does not do any checking that the mode
   * is different to current state so always updates.
   */
  protected void updateUIForMode() {
    // Remove Header, and then add Header Loading View again if needed
    if (this == mHeaderLayout.getParent()) {
      removeView(mHeaderLayout);
    }
    if (mMode.canPullDown()) {
      LinearLayout.LayoutParams llp =
          new LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      llp.setMargins(mMargin, 0, mMargin, 0);
      addViewInternal(mHeaderLayout, 0, llp);
    }

    // Remove Footer, and then add Footer Loading View again if needed
    if (this == mFooterLayout.getParent()) {
      removeView(mFooterLayout);
    }
    if (mMode.canPullUp()) {
      LinearLayout.LayoutParams llp =
          new LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      llp.setMargins(mMargin, 0, mMargin, 0);
      addViewInternal(mFooterLayout, 0, llp);
    }

    // Hide Loading Views
    refreshLoadingViewsHeight();

    // If we're not using Mode.BOTH, set mCurrentMode to mMode, otherwise
    // set it to pull down
    mCurrentMode = (mMode != Mode.BOTH) ? mMode : Mode.PULL_DOWN_TO_REFRESH;
  }
Example #30
0
  /**
   * Add buttons to the Dialog which has button area.
   *
   * @param context
   * @param buttonType The type of button that want to adds to Dialog. TCLAlertDialog.ONE_BUTTON :
   *     adds only one button. TCLAlertDialog.TWO_BUTTON : adds two button. Other : adds custom
   *     button.
   */
  public View setButton(Context context, int buttonType) {
    LayoutInflater inflate =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    switch (buttonType) {
      case ONE_BUTTON:
        // mButtonView =
        // inflate.inflate(com.android.internal.R.layout.tcl_alert_button_one_especial, null);
        break;
      case TWO_BUTTON:
        mButtonView =
            inflate.inflate(com.android.internal.R.layout.tcl_alert_button_two_especial, null);
        break;
      case THREE_BUTTON:
        mButtonView =
            inflate.inflate(com.android.internal.R.layout.tcl_alert_button_three_especial, null);
        break;
      default:
        mButtonView = inflate.inflate(buttonType, null);
        break;
    }
    LinearLayout layout = getLayout(mButtonLayout.getId());

    lp.width = 700; // add by gaodw.
    // lp.height = 150; //add by gaodw.

    layout.addView(mButtonView, lp);
    return mButtonView;
  }