Example usage for android.widget ImageView setTag

List of usage examples for android.widget ImageView setTag

Introduction

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

Prototype

public void setTag(final Object tag) 

Source Link

Document

Sets the tag associated with this view.

Usage

From source file:org.digitalcampus.oppia.widgets.QuizWidget.java

public void showQuestion() {
    QuizQuestion q;//from w ww  . ja  va 2  s. c  o m
    try {
        q = this.quiz.getCurrentQuestion();
    } catch (InvalidQuizException e) {
        Toast.makeText(super.getActivity(), super.getActivity().getString(R.string.error_quiz_no_questions),
                Toast.LENGTH_LONG).show();
        e.printStackTrace();
        return;
    }
    qText.setVisibility(View.VISIBLE);
    // convert in case has any html special chars
    qText.setText(Html
            .fromHtml(
                    q.getTitle(prefs.getString(PrefsActivity.PREF_LANGUAGE, Locale.getDefault().getLanguage())))
            .toString());

    if (q.getProp("image") == null) {
        questionImage.setVisibility(View.GONE);
    } else {
        String fileUrl = course.getLocation() + q.getProp("image");
        // File file = new File(fileUrl);
        Bitmap myBitmap = BitmapFactory.decodeFile(fileUrl);
        File file = new File(fileUrl);
        ImageView iv = (ImageView) getView().findViewById(R.id.question_image_image);
        iv.setImageBitmap(myBitmap);
        iv.setTag(file);
        if (q.getProp("media") == null) {
            OnImageClickListener oicl = new OnImageClickListener(super.getActivity(), "image/*");
            iv.setOnClickListener(oicl);
            TextView tv = (TextView) getView().findViewById(R.id.question_image_caption);
            tv.setText(R.string.widget_quiz_image_caption);
            questionImage.setVisibility(View.VISIBLE);
        } else {
            TextView tv = (TextView) getView().findViewById(R.id.question_image_caption);
            tv.setText(R.string.widget_quiz_media_caption);
            OnMediaClickListener omcl = new OnMediaClickListener(q.getProp("media"));
            iv.setOnClickListener(omcl);
            questionImage.setVisibility(View.VISIBLE);
        }

    }

    if (q instanceof MultiChoice) {
        qw = new MultiChoiceWidget(super.getActivity(), getView(), container);
    } else if (q instanceof MultiSelect) {
        qw = new MultiSelectWidget(super.getActivity(), getView(), container);
    } else if (q instanceof ShortAnswer) {
        qw = new ShortAnswerWidget(super.getActivity(), getView(), container);
    } else if (q instanceof Matching) {
        qw = new MatchingWidget(super.getActivity(), getView(), container);
    } else if (q instanceof Numerical) {
        qw = new NumericalWidget(super.getActivity(), getView(), container);
    } else if (q instanceof Description) {
        qw = new DescriptionWidget(super.getActivity(), getView(), container);
    } else {
        return;
    }
    qw.setQuestionResponses(q.getResponseOptions(), q.getUserResponses());
    this.setProgress();
    this.setNav();
}

From source file:org.xbmc.kore.ui.sections.video.TVShowDetailsFragment.java

/**
 * Display next episode list/*from  www.  j a  v  a 2 s .  c  o  m*/
 *
 * @param cursor Cursor with the data
 */
private void displayNextEpisodeList(Cursor cursor) {
    if (cursor.moveToFirst()) {
        nextEpisodeTitle.setVisibility(View.VISIBLE);
        nextEpisodeList.setVisibility(View.VISIBLE);

        HostManager hostManager = HostManager.getInstance(getActivity());

        View.OnClickListener episodeClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listenerActivity.onNextEpisodeSelected((int) v.getTag());
            }
        };

        // Get the art dimensions
        Resources resources = getActivity().getResources();
        int artWidth = (int) (resources.getDimension(R.dimen.episodelist_art_width)
                / UIUtils.IMAGE_RESIZE_FACTOR);
        int artHeight = (int) (resources.getDimension(R.dimen.episodelist_art_heigth)
                / UIUtils.IMAGE_RESIZE_FACTOR);

        nextEpisodeList.removeAllViews();
        do {
            int episodeId = cursor.getInt(NextEpisodesListQuery.EPISODEID);
            String title = cursor.getString(NextEpisodesListQuery.TITLE);
            String seasonEpisode = String.format(getString(R.string.season_episode),
                    cursor.getInt(NextEpisodesListQuery.SEASON), cursor.getInt(NextEpisodesListQuery.EPISODE));
            int runtime = cursor.getInt(NextEpisodesListQuery.RUNTIME) / 60;
            String duration = runtime > 0
                    ? String.format(getString(R.string.minutes_abbrev), String.valueOf(runtime)) + "  |  "
                            + cursor.getString(NextEpisodesListQuery.FIRSTAIRED)
                    : cursor.getString(NextEpisodesListQuery.FIRSTAIRED);
            String thumbnail = cursor.getString(NextEpisodesListQuery.THUMBNAIL);

            View episodeView = LayoutInflater.from(getActivity()).inflate(R.layout.list_item_next_episode,
                    nextEpisodeList, false);

            ImageView artView = (ImageView) episodeView.findViewById(R.id.art);
            TextView titleView = (TextView) episodeView.findViewById(R.id.title);
            TextView detailsView = (TextView) episodeView.findViewById(R.id.details);
            TextView durationView = (TextView) episodeView.findViewById(R.id.duration);

            titleView.setText(title);
            detailsView.setText(seasonEpisode);
            durationView.setText(duration);

            UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, thumbnail, title, artView,
                    artWidth, artHeight);
            episodeView.setTag(episodeId);
            episodeView.setOnClickListener(episodeClickListener);

            // For the popupmenu
            ImageView contextMenu = (ImageView) episodeView.findViewById(R.id.list_context_menu);
            contextMenu.setTag(episodeId);
            contextMenu.setOnClickListener(contextlistItemMenuClickListener);

            nextEpisodeList.addView(episodeView);
        } while (cursor.moveToNext());
    } else {
        // No episodes, hide views
        nextEpisodeTitle.setVisibility(View.GONE);
        nextEpisodeList.setVisibility(View.GONE);
    }
}

From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java

/**
 * Drop again a movement in the moneybox making an animation.
 * /*  ww  w.ja  v  a 2s .c om*/
 * @param m
 *            Movement to be dropped.
 */
public void dropAgainMovement(Movement m) {
    ImageView v;
    CurrencyValueDef c;

    // TODO: This doesn't work!!!!!!

    c = CurrencyManager.getCurrencyDef(Math.abs(m.getAmount()));

    v = new ImageView(getActivity());
    v.setLeft(findLayout().getWidth() / 2);
    v.setTop(0);
    v.setImageDrawable(c.getDrawable());
    v.setTag(c);

    dropMoney(v, m);
}

From source file:com.githang.androidkit.app.IntroActivity.java

/**
 * /*from w w  w .ja  v  a 2 s.  co  m*/
 */
private void createContentView() {
    // ?
    mIntroResource = new IntroResource();
    setIntroViews(mIntroResource);

    // 
    RelativeLayout rootView = new RelativeLayout(this);
    rootView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    // 
    mViewPager = new ViewPager(this);
    RelativeLayout.LayoutParams pagerParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    rootView.addView(mViewPager, pagerParams);

    // 
    LinearLayout indicatorLayout = new LinearLayout(this);
    RelativeLayout.LayoutParams indicatorParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    indicatorParams.bottomMargin = mIntroResource.indicatorMarginBottom;
    indicatorParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    indicatorParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    indicatorLayout.setLayoutParams(indicatorParams);
    indicatorLayout.setOrientation(LinearLayout.HORIZONTAL);

    // 
    int indicatorCount = mIntroResource.views.size();
    int padding = mIntroResource.indicatorImagePadding;
    mIndicator = new ArrayList<ImageView>();
    for (int i = 0; i < indicatorCount; i++) {
        ImageView imageView = new ImageView(this);
        LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        imageView.setPadding(padding, padding, padding, padding);
        imageView.setClickable(true);
        imageView.setOnClickListener(this);
        imageView.setImageResource(mIntroResource.indicatorNoSelectedId);
        imageView.setTag(i);
        mIndicator.add(imageView);
        indicatorLayout.addView(imageView, imageParams);
    }

    rootView.addView(indicatorLayout);

    setContentView(rootView);
}

From source file:com.lurencun.cfuture09.androidkit.uilibs.IntroActivity.java

/**
 * /*from   ww w  . j a v  a  2  s.  c  o  m*/
 */
private void createContentView() {
    // ?
    mIntroResource = new IntroResource();
    setIntroViews(mIntroResource);

    // 
    RelativeLayout rootView = new RelativeLayout(this);
    rootView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    // 
    mViewPager = new ViewPager(this);
    RelativeLayout.LayoutParams pagerParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
    rootView.addView(mViewPager, pagerParams);

    // 
    LinearLayout indicatorLayout = new LinearLayout(this);
    RelativeLayout.LayoutParams indicatorParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    indicatorParams.bottomMargin = mIntroResource.indicatorMarginBottom;
    indicatorParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    indicatorParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    indicatorLayout.setLayoutParams(indicatorParams);
    indicatorLayout.setOrientation(LinearLayout.HORIZONTAL);

    // 
    int indicatorCount = mIntroResource.views.size();
    int padding = mIntroResource.indicatorImagePadding;
    mIndicator = new ArrayList<ImageView>();
    for (int i = 0; i < indicatorCount; i++) {
        ImageView imageView = new ImageView(this);
        LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        imageView.setPadding(padding, padding, padding, padding);
        imageView.setClickable(true);
        imageView.setOnClickListener(this);
        imageView.setImageResource(mIntroResource.indicatorNoSelectedId);
        imageView.setTag(i);
        mIndicator.add(imageView);
        indicatorLayout.addView(imageView, imageParams);
    }

    rootView.addView(indicatorLayout);

    setContentView(rootView);
}

From source file:com.android.inputmethod.keyboard.EmojiPalettesView.java

@Override
protected void onFinishInflate() {
    mTabHost = (TabHost) findViewById(R.id.emoji_category_tabhost);
    mTabHost.setup();//ww  w .j  av  a 2s . co  m
    for (final CategoryProperties properties : mEmojiCategory.getShownCategories()) {
        addTab(mTabHost, properties.mCategoryId);
    }
    mTabHost.setOnTabChangedListener(this);
    mTabHost.getTabWidget().setStripEnabled(true);

    mEmojiPalettesAdapter = new EmojiPalettesAdapter(mEmojiCategory, mLayoutSet, this);

    mEmojiPager = (ViewPager) findViewById(R.id.emoji_keyboard_pager);
    mEmojiPager.setAdapter(mEmojiPalettesAdapter);
    mEmojiPager.setOnPageChangeListener(this);
    mEmojiPager.setOffscreenPageLimit(0);
    mEmojiPager.setPersistentDrawingCache(ViewPager.PERSISTENT_NO_CACHE);
    final Resources res = getResources();
    final EmojiLayoutParams emojiLp = new EmojiLayoutParams(res);
    emojiLp.setPagerProperties(mEmojiPager);

    mEmojiCategoryPageIndicatorView = (EmojiCategoryPageIndicatorView) findViewById(
            R.id.emoji_category_page_id_view);
    emojiLp.setCategoryPageIdViewProperties(mEmojiCategoryPageIndicatorView);

    setCurrentCategoryId(mEmojiCategory.getCurrentCategoryId(), true /* force */);

    final LinearLayout actionBar = (LinearLayout) findViewById(R.id.emoji_action_bar);
    emojiLp.setActionBarProperties(actionBar);

    final ImageView deleteKey = (ImageView) findViewById(R.id.emoji_keyboard_delete);
    deleteKey.setTag(Constants.CODE_DELETE);
    deleteKey.setOnTouchListener(mDeleteKeyOnTouchListener);
    final ImageView alphabetKey = (ImageView) findViewById(R.id.emoji_keyboard_alphabet);
    alphabetKey.setBackgroundResource(mEmojiFunctionalKeyBackgroundId);
    alphabetKey.setTag(Constants.CODE_SWITCH_ALPHA_SYMBOL);
    alphabetKey.setOnClickListener(this);
    final ImageView spaceKey = (ImageView) findViewById(R.id.emoji_keyboard_space);
    spaceKey.setBackgroundResource(mKeyBackgroundId);
    spaceKey.setTag(Constants.CODE_SPACE);
    spaceKey.setOnClickListener(this);
    emojiLp.setKeyProperties(spaceKey);
    final ImageView alphabetKey2 = (ImageView) findViewById(R.id.emoji_keyboard_alphabet2);
    alphabetKey2.setBackgroundResource(mEmojiFunctionalKeyBackgroundId);
    alphabetKey2.setTag(Constants.CODE_SWITCH_ALPHA_SYMBOL);
    alphabetKey2.setOnClickListener(this);
}

From source file:net.jongrakko.zipsuri.activity.PostReviseActivity.java

private void removeImage(int index) {
    for (int i = index; i < postImageViewIds.length - 1; i++) {
        int nextIndex = i + 1;
        ImageView nowImage = (ImageView) rootView.findViewById(postImageViewIds[i]);
        ImageView nextImage = (ImageView) rootView.findViewById(postImageViewIds[nextIndex]);

        nowImage.setImageDrawable(nextImage.getDrawable());
        nowImage.setTag(nextImage.getTag());
        rootView.findViewById(postImageViewPlusIds[i])
                .setVisibility(rootView.findViewById(postImageViewPlusIds[nextIndex]).getVisibility());
        rootView.findViewById(postImageViewRemoveIds[i])
                .setVisibility(rootView.findViewById(postImageViewRemoveIds[nextIndex]).getVisibility());

        if (nowImage.getTag() == null) {
            nowImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        } else {/*from ww w  . ja  va2s  . co m*/
            nowImage.setScaleType(ImageView.ScaleType.FIT_XY);
        }
    }
    int lastIndex = postImageViewIds.length - 1;
    ImageView lastImage = (ImageView) rootView.findViewById(postImageViewIds[lastIndex]);
    lastImage.setImageResource(R.drawable.ic_add_photo);
    lastImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    lastImage.setTag(null);
    rootView.findViewById(postImageViewPlusIds[lastIndex]).setVisibility(View.GONE);
    rootView.findViewById(postImageViewRemoveIds[lastIndex]).setVisibility(View.GONE);

}

From source file:com.roach.framework.http.bitmap.ImageWorker.java

public void recycleBitmap(ImageView iv) {
    BitmapWorkerTask bitmapWorkerTask = null;
    if (iv.getTag() != null && (iv.getTag() instanceof BitmapWorkerTask)) {
        bitmapWorkerTask = (BitmapWorkerTask) iv.getTag();
    }//from   w  w w  .j  a  v  a  2 s  .c om
    if (bitmapWorkerTask != null) {
        Bitmap bitmap = bitmapWorkerTask.getBitmap();
        iv.setImageBitmap(null);
        if (bitmap != null && !bitmap.isRecycled()) {
            bitmap.recycle();
        }
        iv.setTag(null);
        bitmapWorkerTask = null;
    }
}

From source file:org.eyeseetea.malariacare.DashboardActivity.java

private void addTagToLastTab(String tabName) {
    TabWidget tabWidget = tabHost.getTabWidget();
    int numTabs = tabWidget.getTabCount();
    ViewGroup tabIndicator = (ViewGroup) tabWidget.getChildTabViewAt(numTabs - 1);

    ImageView imageView = (ImageView) tabIndicator.getChildAt(0);
    imageView.setTag(tabName);
    TextView textView = (TextView) tabIndicator.getChildAt(1);
    textView.setGravity(Gravity.CENTER);
    textView.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
    textView.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;

}

From source file:br.org.funcate.dynamicforms.views.GPictureView.java

private ImageView getImageView(final Context context, Bitmap photo, String uuid) {
    ImageView imageView = new ImageView(context);
    imageView.setLayoutParams(new LinearLayout.LayoutParams(thumbnailWidth, thumbnailHeight));
    imageView.setPadding(5, 5, 5, 5);/*  w  ww.jav  a  2 s  .com*/
    imageView.setImageBitmap(photo);
    imageView.setBackgroundDrawable(getResources().getDrawable(R.drawable.border_black_1px));
    imageView.setTag(uuid);
    imageView.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            String photoId = (String) v.getTag();

            FragmentActivity activity = mFragmentDetail.getActivity();
            Intent intent = new Intent(activity, PictureActivity.class);

            if (addedIdsToImageViews.containsKey(photoId)) {// pictures on session
                intent.putExtra(FormUtilities.PICTURE_PATH_VIEW, addedIdsToImageViews.get(photoId));
            } else if (_pictures.containsKey(photoId)) {// pictures from database

                Map<String, String> imagePaths = _pictures.get(photoId);
                String imagePath = imagePaths.get("display");

                intent.putExtra(FormUtilities.PICTURE_DB_VIEW, imagePath);// Image temporary path
            }
            if (intent.hasExtra(FormUtilities.PICTURE_PATH_VIEW)
                    || intent.hasExtra(FormUtilities.PICTURE_DB_VIEW)) {
                intent.putExtra(FormUtilities.PICTURE_BITMAP_ID, photoId);
                activity.startActivityForResult(intent, PICTURE_VIEW_RESULT);
            } else
                Toast.makeText(getContext(), "Fail, the picture not found.", Toast.LENGTH_LONG).show();

            /*
            JSONArray form = null;
            try {
            form = mFragmentDetail.getSelectedForm();
            } catch (JSONException jse) {
            jse.printStackTrace();
            Toast.makeText(getContext(), jse.getMessage(), Toast.LENGTH_LONG).show();
            }
                    
            if (form != null) {
            try {
                String json = encodeToJson();
                FormUtilities.updatePicture(form, json);
            } catch (JSONException e) {
                e.printStackTrace();
            }catch (Exception e) {
                e.printStackTrace();
            }
            }
            try {
            refresh(getContext());
            } catch (Exception e) {
            e.printStackTrace();
            Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
            }*/
            /**
             * open in markers to edit it
             */
            // MarkersUtilities.launchOnImage(context, image);
            /* try {
                 Intent intent = new Intent();
                 intent.setAction(Intent.ACTION_VIEW);
                 Image image = imagesDbHelper.getImage(imageIdLong);
                 File tempDir = ResourcesManager.getInstance(context).getTempDir();
                 String ext = ".jpg";
                 if (image.getName().endsWith(".png"))
                     ext = ".png";
                 File imageFile = new File(tempDir, ImageUtilities.getTempImageName(ext));
                 byte[] imageData = imagesDbHelper.getImageData(image.getId());
                 ImageUtilities.writeImageDataToFile(imageData, imageFile.getAbsolutePath());
                    
                 intent.setDataAndType(Uri.fromFile(imageFile), "image*//**//*"); //$NON-NLS-1$
                                                                             context.startActivity(intent);
                                                                             } catch (Exception e) {
                                                                             //GPLog.error(this, null, e);
                                                                             Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
                                                                             }*/
            //Toast.makeText(getContext(), "Implement this action", Toast.LENGTH_LONG).show();

        }
    });
    return imageView;
}