Example usage for android.widget ImageView ImageView

List of usage examples for android.widget ImageView ImageView

Introduction

In this page you can find the example usage for android.widget ImageView ImageView.

Prototype

public ImageView(Context context) 

Source Link

Usage

From source file:com.astuetz.PagerSlidingTitleIconTabStrip.java

private void addTextIconTab(final int position, String title, int resId) {

    if (resId == TitleIconTabProvider.NONE_ICON) {
        addTextTab(position, title);/*from w  w w. ja v a  2 s  . c o m*/
        return;
    }

    TextView tab = new TextView(getContext());
    tab.setText(title);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    ImageView icon = new ImageView(getContext());
    icon.setImageResource(resId);

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

    linearLayout.addView(icon, defaultTabLayoutParams);
    linearLayout.addView(tab, defaultTabLayoutParams);

    addTab(position, linearLayout);
}

From source file:com.jgkj.bxxc.fragment.IndexFragment2.java

private void scrollView() {
    SharedPreferences sp = getActivity().getSharedPreferences("PicCount", Activity.MODE_PRIVATE);
    final int count = sp.getInt("Count", -1);
    if (count != -1) {
        final ImageView[] dots = new ImageView[count];
        for (int k = 0; k < count; k++) {
            ImageView image = new ImageView(getActivity());
            image.setImageDrawable(getResources().getDrawable(R.drawable.selector));
            image.setId(k);/*from  w ww.  j a va  2 s.  com*/
            wrapParams = new LinearLayout.LayoutParams(ViewPager.LayoutParams.WRAP_CONTENT,
                    ViewPager.LayoutParams.WRAP_CONTENT);
            wrapParams.leftMargin = 5;
            image.setLayoutParams(wrapParams);
            linearlayout.addView(image);
            dots[k] = (ImageView) linearlayout.getChildAt(k);
            dots[k].setEnabled(true);
        }
        final Handler mHandler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                if (currentItem < (count - 1)) {
                    currentItem++;
                    viewpager.setCurrentItem(currentItem);
                } else if (currentItem == (count - 1)) {
                    currentItem = 0;
                    viewpager.setCurrentItem(currentItem);
                }
                for (int j = 0; j < count; j++) {
                    dots[j].setEnabled(false);
                }
                dots[currentItem].setEnabled(true);
            }
        };
        TimerTask timerTask = new TimerTask() {
            @Override
            public void run() {
                mHandler.sendEmptyMessage(0);
            }
        };
        timer.schedule(timerTask, 1000, 3000);
    }
}

From source file:com.liangxun.university.huanxin.chat.activity.ChatActivity.java

/**
 * ?/*from   www .j ava  2  s . c om*/
 */
private void Init_Point() {

    pointViews = new ArrayList<ImageView>();
    ImageView imageView;
    for (int i = 0; i < views.size(); i++) {
        imageView = new ImageView(this);
        imageView.setBackgroundResource(R.drawable.d1);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(new ViewGroup.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT));
        layoutParams.leftMargin = 10;
        layoutParams.rightMargin = 10;
        layoutParams.width = 8;
        layoutParams.height = 8;
        layout_point.addView(imageView, layoutParams);
        //            if (i == 0 || i == views.size() - 1) {
        //                imageView.setVisibility(View.GONE);
        //            }
        if (i == 0) {
            imageView.setBackgroundResource(R.drawable.d2);
        }
        pointViews.add(imageView);

    }
}

From source file:com.haomee.view.PagerSlidingTabStrip.java

private void addTextIconTab(final int position, String title, int resId) {

    if (resId == TitleIconTabProvider.NONE_ICON) {
        addTextTab(position, title);//w ww . ja  v a2  s.co  m
        return;
    }

    TextView tab = new TextView(getContext());
    tab.setText(title);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    ImageView icon = new ImageView(getContext());
    icon.setImageResource(resId);

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

    linearLayout.addView(tab, defaultTabLayoutParams);
    linearLayout.addView(icon, defaultTabLayoutParams);

    addTab(position, linearLayout);
}

From source file:com.xxjwd.sjbg.MainActivity.java

 private void doShowDownloadDialog() {
   Dialog builder = new Dialog(this);
    //builder.requestWindowFeature(Window.FEATURE_NO_TITLE);
   builder.setTitle("???");
    builder.getWindow().setBackgroundDrawable(
        new ColorDrawable(android.graphics.Color.TRANSPARENT));
    builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override/*from w ww .  j a  v a 2s.c  o  m*/
        public void onDismiss(DialogInterface dialogInterface) {
            //nothing;
        }
    });

    ImageView imageView = new ImageView(this);
    imageView.setImageResource(R.drawable.erweima);
   imageView.setOnLongClickListener(new OnLongClickListener()
   {

      @Override
      public boolean onLongClick(View v) {
         // TODO Auto-generated method stub
         Intent intent = new Intent();        
           intent.setAction("android.intent.action.VIEW");    
           Uri content_url = Uri.parse("http://61.163.45.215:808/sjbg/download.html");   
           intent.setData(content_url);  
           startActivity(intent);
         return true;
      }
   }
   );
    builder.addContentView(imageView, new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, 
            ViewGroup.LayoutParams.WRAP_CONTENT));
    builder.show();
      
}

From source file:com.yktx.check.widget.OldPagerSlidingTabStrip.java

private void addIconAndTextTab(final int position, int resId, String title) {
    LinearLayout layout = new LinearLayout(getContext());
    layout.setGravity(Gravity.CENTER);//from  w w  w .  j a va 2 s.  c  om
    layout.setOrientation(LinearLayout.VERTICAL);
    ImageView tabImage = new ImageView(getContext());
    tabImage.setImageResource(resId);
    tabImage.setId(R.id.image);
    TextView tabText = new TextView(getContext());
    tabText.setText(title);
    tabText.setSingleLine();
    tabText.setId(R.id.text);
    tabText.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    tabText.setGravity(Gravity.CENTER_HORIZONTAL);
    tabText.setPadding(0, 3, 0, 0);
    layout.addView(tabImage);
    layout.addView(tabText);

    addTab(position, layout);

}

From source file:com.example.meetingapp.ShowDetailsFragment.java

/**
 * Adds an image to the HorizontalScrollView.
 * @param image Image to be added to the HorizontalScrollView.
 *//*from w w  w .jav a  2 s  .  co  m*/
private void addImage(Bitmap image) {
    LinearLayout layout = new LinearLayout(getActivity());
    layout.setGravity(Gravity.CENTER);

    /* Set parameters - we want a small divider of 3 pixels so we can
     * easily distinguish different photos.
     */
    LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.setMargins(3, 0, 0, 0);
    params.gravity = Gravity.CENTER;

    ImageView imageView = new ImageView(getActivity());
    imageView.setScaleType(ScaleType.CENTER);
    imageView.setImageBitmap(image);
    imageView.setLayoutParams(params);

    layout.addView(imageView);
    mPhotosView.addView(layout);
}

From source file:io.github.douglasjunior.androidSimpleTooltip.SimpleTooltip.java

private void configContentView() {
    if (mContentView instanceof TextView) {
        TextView tv = (TextView) mContentView;
        tv.setText(mText);//from   ww  w . jav a  2s  .  c  o  m
    } else {
        TextView tv = (TextView) mContentView.findViewById(mTextViewId);
        if (tv != null)
            tv.setText(mText);
    }

    mContentView.setPadding(mPadding, mPadding, mPadding, mPadding);

    if (mShowArrow) {
        mArrowView = new ImageView(mContext);
        mArrowView.setImageDrawable(mArrowDrawable);
        LinearLayoutCompat.LayoutParams arrowLayoutParams;
        if (mGravity == Gravity.TOP || mGravity == Gravity.BOTTOM) {
            arrowLayoutParams = new LinearLayoutCompat.LayoutParams((int) mArrowWidth, (int) mArrowHeight, 0);
        } else {
            arrowLayoutParams = new LinearLayoutCompat.LayoutParams((int) mArrowHeight, (int) mArrowWidth, 0);
        }
        mArrowView.setLayoutParams(arrowLayoutParams);
        LinearLayoutCompat linearLayout = new LinearLayoutCompat(mContext);
        linearLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        linearLayout.setOrientation(
                mGravity == Gravity.START || mGravity == Gravity.END ? LinearLayoutCompat.HORIZONTAL
                        : LinearLayoutCompat.VERTICAL);
        int padding = mAnimated ? mAnimationPadding : (int) SimpleTooltipUtils.pxFromDp(4);
        linearLayout.setPadding(padding, padding, padding, padding);

        if (mGravity == Gravity.TOP || mGravity == Gravity.START) {
            linearLayout.addView(mContentView);
            linearLayout.addView(mArrowView);
        } else {
            linearLayout.addView(mArrowView);
            linearLayout.addView(mContentView);
        }

        LinearLayoutCompat.LayoutParams contentViewParams = new LinearLayoutCompat.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0);
        contentViewParams.gravity = Gravity.CENTER;
        mContentView.setLayoutParams(contentViewParams);

        mContentLayout = linearLayout;
    } else {
        mContentLayout = mContentView;
        mContentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
    }
    mContentLayout.setVisibility(View.INVISIBLE);
    mPopupWindow.setContentView(mContentLayout);
}

From source file:com.younchen.emoji.ui.tab.PagerSlidingTabStrip.java

private void addIconTab(final int position, String imgUrl) {
    //      final ImageButton tab = new ImageButton(getContext());
    ImageView imageView = new ImageView(getContext());
    addTab(position, imageView);/*from   www  .  j a  va  2s . c o  m*/
    EmojiLoaderManager.getInstance().getEvn().getImageLoader().loadImage(imageView, imgUrl,
            tabBackgroundImageMaxHeight, tabBackgroundImageMaxWidth);
}

From source file:com.luke.lukef.lukeapp.popups.SubmissionPopup.java

/**
 * Adds imageviews to the categories section of the popup, with the thumbnails of the categories.
 * Dimensions of the parent view can only be retreived once they are drawn, so a
 * GlobalLayoutListener is needed./*from w w  w. j  av a  2s . co  m*/
 *
 * @param categories list of categories whose images are to be added to the category list
 */
private void setCategories(List<Category> categories) {
    for (Category c : categories) {
        final ImageView categoryImg = new ImageView(this.mainActivity);
        categoryImg.setImageBitmap(c.getImage());
        final LinearLayout.LayoutParams[] layoutParams = new LinearLayout.LayoutParams[1];
        this.submissionCategoriesLinear.getViewTreeObserver()
                .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                    @Override
                    public void onGlobalLayout() {
                        layoutParams[0] = new LinearLayout.LayoutParams(new LinearLayout.LayoutParams(
                                SubmissionPopup.this.submissionCategoriesLinear.getHeight(),
                                SubmissionPopup.this.submissionCategoriesLinear.getHeight()));
                        categoryImg.setLayoutParams(layoutParams[0]);
                        if (categoryImg.getParent() != null) {
                            ((ViewGroup) categoryImg.getParent()).removeView(categoryImg);
                        }
                        SubmissionPopup.this.submissionCategoriesLinear.addView(categoryImg);
                    }
                });
    }
}