Example usage for android.widget ImageView setImageResource

List of usage examples for android.widget ImageView setImageResource

Introduction

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

Prototype

@android.view.RemotableViewMethod(asyncImpl = "setImageResourceAsync")
public void setImageResource(@DrawableRes int resId) 

Source Link

Document

Sets a drawable as the content of this ImageView.

Usage

From source file:com.app.sample.chatting.adapter.chat.FaceCategroyAdapter.java

@Override
public void setPageIcon(int position, ImageView image) {
    if (position == 0) {
        image.setImageResource(R.drawable.icon_face_click);
        return;/*from w  w  w. j  a v a2 s.  co m*/
    }
    File file = new File(datas.get(position - 1));
    String path = null;
    for (int i = 0; i < file.list().length; i++) {
        path = file.list()[i];
        if (path.endsWith(".png") || path.endsWith(".jpg") || path.endsWith(".jpeg")) {
            break;
        }
    }
    Bitmap bitmap = BitmapCreate.bitmapFromFile(file.getAbsolutePath() + "/" + path, 40, 40);
    image.setImageBitmap(bitmap);
}

From source file:com.ketanolab.simidic.adapters.AdaptadorViewPager.java

@Override
public Object instantiateItem(View collection, int position) {
    LinearLayout linearLayout = (LinearLayout) View.inflate(contexto, R.layout.diccionario2, null);

    // titulo/*from w w  w.  ja  v a2 s.  co  m*/
    TextView textoTitulo = (TextView) linearLayout.findViewById(R.id.textview_titulo);
    textoTitulo.setText(listaTitulos.get(position));
    // Subtitulo
    TextView textoSubtitulo = (TextView) linearLayout.findViewById(R.id.textview_subtitulo);
    textoSubtitulo.setText(listaSubtitulos.get(position));
    // Extra
    TextView textoExtra = (TextView) linearLayout.findViewById(R.id.textview_extra);
    textoExtra.setText(listaExtras.get(position));
    textoExtra.setMovementMethod(LinkMovementMethod.getInstance());
    // Imagen
    ImageView imagen = (ImageView) linearLayout.findViewById(R.id.imageview_logo);
    imagen.setImageResource(listaBitmaps.get(position));

    ((ViewPager) collection).addView(linearLayout, 0);
    return linearLayout;
}

From source file:com.betterzw.app.demo.adapter.GoodsDetailPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    View rootLayout = mInflater.inflate(R.layout.goods_detail_picture_item, container, false);
    final ImageView thumbIv = (ImageView) rootLayout.findViewById(R.id.goods_picture_iv_Thumb);

    thumbIv.setImageResource(image[position]);

    ((ViewPager) container).addView(rootLayout, 0);
    return rootLayout;
}

From source file:MainAdapter.java

@Override
public void onBindViewHolder(final MainViewHolder holder, final int position) {

    ImageView imageIcon = holder.imageIcon;
    TextView textName = holder.textName;
    TextView textInfo = holder.textInfo;

    imageIcon.setImageResource(mainData.get(position).getImage());
    textName.setText(mainData.get(position).getName());
    textInfo.setText(mainData.get(position).getInfo());
}

From source file:com.icanvass.fragments.ScreenSlidePageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout containing a title and body text.
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_screen_slide_page, container, false);

    // Set the title view to show the page number.
    //        ((TextView) rootView.findViewById(android.R.id.text1)).setText(
    //                getString("step", mPageNumber + 1));
    ImageView iv = (ImageView) rootView.findViewById(R.id.tutimage);
    iv.setImageBitmap(null);//  w w  w.j a v  a  2 s. c  om
    iv.setImageResource(images[mPageNumber]);

    return rootView;
}

From source file:com.google.android.apps.santatracker.presentquest.ui.PlayGameDialog.java

@Nullable
@Override//ww  w  .j  a v  a 2s  . co  m
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.dialog_play_minigame, container, false);

    // Play text
    FontHelper.makeLobster((TextView) rootView.findViewById(R.id.minigame_text));

    // Game image
    ImageView imageView = (ImageView) rootView.findViewById(R.id.minigame_image);
    imageView.setImageResource(getImageResourceId());

    // Click listener
    rootView.findViewById(R.id.dialog_root).setOnClickListener(this);

    return rootView;
}

From source file:com.aokp.romcontrol.github.tasks.GetJSONChangelogTask.java

protected void onPreExecute() {
    // start with a clean view, always
    mCategory.removeAll();/*from w w w  . j  a va  2 s  . c o m*/
    mCategory.setTitle(mContext.getString(R.string.loading_projects));
    if (mProgressDialog == null) {
        mProgressDialog = new ProgressDialog(mAlertDialog.getContext());
        ImageView imageView = new ImageView(mContext);
        imageView.setImageResource(R.drawable.octacat);
        mProgressDialog.show();
        mProgressDialog.setContentView(R.layout.github_octacat);
    }
}

From source file:co.bytera.twodimensionalviewpager.adapter.TwoDimensionalViewPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {

    @SuppressWarnings("static-access")
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);

    /*//  w  ww .  j av a  2s .c  o m
     * Layout is created from xml here, but it can be done by java coding as well
     */
    View view = inflater.inflate(R.layout.view_page, null);

    TextView textView = (TextView) view.findViewById(R.id.textView1);
    textView.setText(rowNumber + ", " + position);

    ImageView imageView = (ImageView) view.findViewById(R.id.imageView1);
    imageView.setImageResource(data[rowNumber][position]);

    container.addView(view);

    return view;
}

From source file:com.groksolutions.grok.mobile.tutorial.TutorialPageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ImageView rootView = (ImageView) inflater.inflate(R.layout.fragment_tutorial_page, container, false);
    rootView.setImageResource(_page);

    return rootView;
}

From source file:com.github.curioustechizen.doubletake.sample.ZoomActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_zoom);

    final ViewGroup container = (ViewGroup) findViewById(R.id.container);
    final View thumb1View = findViewById(R.id.thumb_button_1);

    // Hook up clicks on the thumbnail views.
    thumb1View.setOnClickListener(new View.OnClickListener() {
        @Override/* w  ww .j av  a 2s .  com*/
        public void onClick(View view) {
            // zoomImageFromThumb(thumb1View, R.drawable.image1);
            final ImageView expandedImageView1 = (ImageView) findViewById(R.id.expanded_image);
            expandedImageView1.setImageResource(R.drawable.image1);

            final ZoomAnimation zoomAnimation1 = new ZoomAnimation.Builder(thumb1View, expandedImageView1,
                    container).animationTime(getResources().getInteger(android.R.integer.config_longAnimTime))
                            .build();
            zoomAnimation1.zoomIn();
        }
    });

    final View thumb2View = findViewById(R.id.thumb_button_2);

    thumb2View.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            final ImageView expandedImageView2 = (ImageView) findViewById(R.id.expanded_image);
            final ZoomAnimation zoomAnimation2 = new ZoomAnimation.Builder(thumb2View, expandedImageView2,
                    container).build();
            expandedImageView2.setImageResource(R.drawable.image2);
            zoomAnimation2.zoomIn();
        }
    });
}