Example usage for android.widget ImageView setOnClickListener

List of usage examples for android.widget ImageView setOnClickListener

Introduction

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

Prototype

public void setOnClickListener(@Nullable OnClickListener l) 

Source Link

Document

Register a callback to be invoked when this view is clicked.

Usage

From source file:com.telestax.mayday_customer.fragment.ProductFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View viewInfo = inflater.inflate(R.layout.product, container, false);

    ViewPager viewPager = (ViewPager) viewInfo.findViewById(R.id.view_pager);
    mDotsLayout = (LinearLayout) viewInfo.findViewById(R.id.viewPagerCountDots);

    mInitReceiver = new BroadcastReceiver() {
        @Override/*from  w  ww .j a  v a2s .com*/
        public void onReceive(Context context, Intent intent) {
            mImageViewCustomerMayDayCall.setVisibility(View.VISIBLE);
        }
    };

    //Register broadcast receiver
    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mInitReceiver,
            new IntentFilter(Constant.BROADCAST_INTENT));

    // Initialize UI
    ImageView ImageViewProductOne = (ImageView) viewInfo.findViewById(R.id.imageView_product);
    ImageView ImageViewProductTwo = (ImageView) viewInfo.findViewById(R.id.imageView_product_two);
    ImageView ImageViewProductThree = (ImageView) viewInfo.findViewById(R.id.imageView_product_three);
    ImageView ImageViewProductFour = (ImageView) viewInfo.findViewById(R.id.imageView_product_four);
    ImageView ImageViewProductFive = (ImageView) viewInfo.findViewById(R.id.imageView_product_five);
    ImageView ImageViewProductSix = (ImageView) viewInfo.findViewById(R.id.imageView_product_six);
    ImageView ImageViewProductSeven = (ImageView) viewInfo.findViewById(R.id.imageView_product_seven);

    mImageViewCustomerMayDayCall = (ImageView) viewInfo.findViewById(R.id.imageView_customer_mayday);

    ImageViewProductOne.setOnClickListener(this);
    ImageViewProductTwo.setOnClickListener(this);
    ImageViewProductThree.setOnClickListener(this);
    ImageViewProductFour.setOnClickListener(this);
    ImageViewProductFive.setOnClickListener(this);
    ImageViewProductSix.setOnClickListener(this);
    ImageViewProductSeven.setOnClickListener(this);

    String mayDayAction = MainActivity.getMaydaySharePref(getActivity());
    if (mayDayAction != null) {
        if (mayDayAction.equalsIgnoreCase(Constant.YES)) {
            mImageViewCustomerMayDayCall.setVisibility(View.INVISIBLE);
        } else {
            mImageViewCustomerMayDayCall.setVisibility(View.VISIBLE);
        }
    }

    ImagePagerAdapter adapter = new ImagePagerAdapter();
    viewPager.setAdapter(adapter);
    mDotsLayout.setBaselineAligned(true);
    setUiPageViewController();

    // ViewPager slider event
    viewPager.setOnPageChangeListener(viewPagerPageChangeListener);

    mImageViewCustomerMayDayCall.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final CharSequence[] items = { getResources().getString(R.string.video),
                    getResources().getString(R.string.instant_message), };

            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setTitle(getResources().getString(R.string.action));
            builder.setItems(items, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {
                    if (item == 0) {
                        mCallBack.onVideoCall();
                        mImageViewCustomerMayDayCall.setVisibility(View.INVISIBLE);
                    } else if (item == 1) {
                        mCallBack.onChatMessage();
                        mImageViewCustomerMayDayCall.setVisibility(View.INVISIBLE);

                    }
                }
            });
            AlertDialog alert = builder.create();
            alert.show();
        }
    });
    return viewInfo;
}

From source file:chrisrenke.drawerarrowdrawable.DrawerArrowSample.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home_view);/*from  w ww. j a va 2  s  .  c  o m*/

    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    final ImageView imageView = (ImageView) findViewById(R.id.drawer_indicator);
    final Resources resources = getResources();

    drawerArrowDrawable = new DrawerArrowDrawable(resources);
    drawerArrowDrawable.setStrokeColor(resources.getColor(R.color.green));
    imageView.setImageDrawable(drawerArrowDrawable);

    drawer.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {
        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            offset = slideOffset;
            // Sometimes slideOffset ends up so close to but not quite 1 or 0.
            if (slideOffset >= .995) {
                flipped = true;
                drawerArrowDrawable.setFlip(flipped);
            } else if (slideOffset <= .005) {
                flipped = false;
                drawerArrowDrawable.setFlip(flipped);
            }
            drawerArrowDrawable.setParameter(offset);
        }
    });

    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (drawer.isDrawerVisible(START)) {
                drawer.closeDrawer(START);
            } else {
                drawer.openDrawer(START);
            }
        }
    });

    final TextView styleButton = (TextView) findViewById(R.id.indicator_style);
    styleButton.setOnClickListener(new View.OnClickListener() {
        boolean rounded = false;

        @Override
        public void onClick(View v) {
            styleButton.setText(rounded //
                    ? resources.getString(R.string.rounded) //
                    : resources.getString(R.string.squared));

            rounded = !rounded;

            drawerArrowDrawable = new DrawerArrowDrawable(resources, rounded);
            drawerArrowDrawable.setParameter(offset);
            drawerArrowDrawable.setFlip(flipped);
            drawerArrowDrawable.setStrokeColor(resources.getColor(R.color.light_gray));

            imageView.setImageDrawable(drawerArrowDrawable);
        }
    });
}

From source file:cw.kop.autobackground.tutorial.CardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {

    final View view = AppSettings.getTheme().equals(AppSettings.APP_LIGHT_THEME)
            ? inflater.inflate(R.layout.tutorial_card_fragment, container, false)
            : inflater.inflate(R.layout.tutorial_card_fragment_dark, container, false);
    View sourceCard = view.findViewById(R.id.source_card);
    sourceCard.setOnClickListener(this);

    int colorFilterInt = AppSettings.getColorFilterInt(appContext);

    TextView sourceTitle = (TextView) view.findViewById(R.id.source_title);
    sourceTitle.setOnClickListener(new View.OnClickListener() {
        @Override/*w  ww.j av  a 2  s .c  om*/
        public void onClick(View v) {
            CardFragment.this.onClick(view);
        }
    });

    ImageView deleteButton = (ImageView) view.findViewById(R.id.source_delete_button);
    ImageView viewButton = (ImageView) view.findViewById(R.id.source_view_image_button);
    ImageView editButton = (ImageView) view.findViewById(R.id.source_edit_button);

    Drawable deleteDrawable = getResources().getDrawable(R.drawable.ic_delete_white_24dp);
    Drawable viewDrawable = getResources().getDrawable(R.drawable.ic_photo_white_24dp);
    Drawable editDrawable = getResources().getDrawable(R.drawable.ic_edit_white_24dp);

    deleteDrawable.setColorFilter(colorFilterInt, PorterDuff.Mode.MULTIPLY);
    viewDrawable.setColorFilter(colorFilterInt, PorterDuff.Mode.MULTIPLY);
    editDrawable.setColorFilter(colorFilterInt, PorterDuff.Mode.MULTIPLY);

    deleteButton.setImageDrawable(deleteDrawable);
    viewButton.setImageDrawable(viewDrawable);
    editButton.setImageDrawable(editDrawable);

    deleteButton.setOnClickListener(null);
    viewButton.setOnClickListener(null);
    editButton.setOnClickListener(null);

    TextView sourceType = (TextView) view.findViewById(R.id.source_type);
    TextView sourceData = (TextView) view.findViewById(R.id.source_data);
    TextView sourceNum = (TextView) view.findViewById(R.id.source_num);
    TextView sourceTime = (TextView) view.findViewById(R.id.source_time);

    int colorPrimary = getResources().getColor(R.color.BLUE_OPAQUE);
    SpannableString typePrefix = new SpannableString("Type: ");
    typePrefix.setSpan(new ForegroundColorSpan(colorPrimary), 0, typePrefix.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    SpannableString dataPrefix = new SpannableString("Data: ");
    dataPrefix.setSpan(new ForegroundColorSpan(colorPrimary), 0, dataPrefix.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    SpannableString numPrefix = new SpannableString("Number of Images: ");
    numPrefix.setSpan(new ForegroundColorSpan(colorPrimary), 0, numPrefix.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    SpannableString timePrefix = new SpannableString("Active Time: ");
    timePrefix.setSpan(new ForegroundColorSpan(colorPrimary), 0, timePrefix.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    sourceType.setText(typePrefix);
    sourceData.setText(dataPrefix);
    sourceNum.setText(numPrefix);
    sourceTime.setText(timePrefix);

    ImageView image = (ImageView) view.findViewById(R.id.source_image);
    Picasso.with(appContext).load(R.drawable.preview_image_0).fit().centerCrop().into(image);

    TextView titleText = (TextView) view.findViewById(R.id.title_text);
    titleText.setTextColor(colorFilterInt);
    titleText.setText("Sources");

    TextView tutorialText = (TextView) view.findViewById(R.id.tutorial_text);
    tutorialText.setTextColor(colorFilterInt);
    tutorialText.setText("These are the parts that make up your wallpaper. "
            + "Each represents an image source like an album from Imgur or "
            + "a subreddit. Note that not all websites or entries can work " + "with AutoBackground.");

    return view;
}

From source file:com.cm.android.beercellar.ui.ImageGridFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final View v = inflater.inflate(R.layout.image_grid_fragment, container, false);
    mGridView = (GridView) v.findViewById(R.id.gridView);
    mGridView.setAdapter(mAdapter);/*from   w  ww.ja  v a 2s .  co m*/
    mGridView.setOnItemClickListener(this);
    mGridView.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView absListView, int scrollState) {
            // Pause fetcher to ensure smoother scrolling when flinging
            if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) {
                // Before Honeycomb pause image loading on scroll to help with performance
                if (!Utils.hasHoneycomb()) {
                    mImageFetcher.setPauseWork(true);
                }
            } else {
                mImageFetcher.setPauseWork(false);
            }
        }

        @Override
        public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount,
                int totalItemCount) {
        }
    });

    // This listener is used to get the final width of the GridView and then calculate the
    // number of columns and the width of each column. The width of each column is variable
    // as the GridView has stretchMode=columnWidth. The column width is used to set the height
    // of each view so we get nice square thumbnails.
    mGridView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @TargetApi(VERSION_CODES.JELLY_BEAN)
        @Override
        public void onGlobalLayout() {
            if (mAdapter.getNumColumns() == 0) {
                final int numColumns = (int) Math
                        .floor(mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing));
                if (numColumns > 0) {
                    final int columnWidth = (mGridView.getWidth() / numColumns) - mImageThumbSpacing;
                    mAdapter.setNumColumns(numColumns);
                    mAdapter.setItemHeight(columnWidth);
                    if (BuildConfig.DEBUG) {
                        Log.d(TAG, "onCreateView - numColumns set to " + numColumns);
                    }
                    if (Utils.hasJellyBean()) {
                        mGridView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                    } else {
                        mGridView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                    }
                }
            }
        }
    });

    //@author anshu
    final ImageView mAddImage = (ImageView) v.findViewById(R.id.add_image);
    mAddImage.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                mVibrator.vibrate(250);
                takePhoto();
            } catch (IOException ex) {
                // Error occurred while creating the File
                Log.e("takePhoto", ex.toString());
            }
        }
    });

    //Admob
    mAdView = (AdView) v.findViewById(R.id.adView);

    //constants
    CLOUD_VISION_API_KEY = getActivity().getResources().getString(R.string.cloud_vision_api_key);
    APPLICATION_NAME = getActivity().getResources().getString(R.string.app_name);

    return v;
}

From source file:com.example.drawerarrowdrawable.DrawerArrowSample.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home_view);//from  w  w w  . ja va2s  .  com

    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    final ImageView imageView = (ImageView) findViewById(R.id.drawer_indicator);
    final Resources resources = getResources();

    drawerArrowDrawable = new DrawerArrowDrawable(resources);
    drawerArrowDrawable.setStrokeColor(resources.getColor(R.color.light_gray));
    imageView.setImageDrawable(drawerArrowDrawable);

    drawer.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {
        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            offset = slideOffset;

            // Sometimes slideOffset ends up so close to but not quite 1 or 0.
            if (slideOffset >= .995) {
                flipped = true;
                drawerArrowDrawable.setFlip(flipped);
            } else if (slideOffset <= .005) {
                flipped = false;
                drawerArrowDrawable.setFlip(flipped);
            }

            drawerArrowDrawable.setParameter(offset);
        }
    });

    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (drawer.isDrawerVisible(START)) {
                drawer.closeDrawer(START);
            } else {
                drawer.openDrawer(START);
            }
        }
    });

    final TextView styleButton = (TextView) findViewById(R.id.indicator_style);
    styleButton.setOnClickListener(new View.OnClickListener() {
        boolean rounded = false;

        @Override
        public void onClick(View v) {
            styleButton.setText(rounded //
                    ? resources.getString(R.string.rounded) //
                    : resources.getString(R.string.squared));

            rounded = !rounded;

            drawerArrowDrawable = new DrawerArrowDrawable(resources, rounded);
            drawerArrowDrawable.setParameter(offset);
            drawerArrowDrawable.setFlip(flipped);
            drawerArrowDrawable.setStrokeColor(resources.getColor(R.color.light_gray));

            imageView.setImageDrawable(drawerArrowDrawable);
        }
    });
}

From source file:com.tecnojin.timekiller.menuviews.GamePageAdapter.java

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

    GameDescriptor descriptor = GameManager.instance(context).getGameFromIndex(context, position);

    View layout = inflater.inflate(R.layout.game_page, null);

    TextView t = (TextView) layout.findViewById(R.id.game_name);
    ImageView icon = (ImageView) layout.findViewById(R.id.gameIcon);

    ImageView sett = (ImageView) layout.findViewById(R.id.settings);
    ImageView tutorial = (ImageView) layout.findViewById(R.id.tutorial);
    ImageView stat = (ImageView) layout.findViewById(R.id.stat);

    if (descriptor.getName() != 0) {
        t.setText(descriptor.getName());
        ActivityUtil.setFont(t, ActivityUtil.FONTS_BATES_SHOWER);
        if (descriptor.isReady())
            icon.setImageResource(descriptor.getIcon());
        else/*from w w w. j  a va 2s  .  c o  m*/
            icon.setImageResource(R.drawable.work);

        if (!descriptor.isReady()) {
            tutorial.setEnabled(false);
            icon.setEnabled(false);
        }
        if (!descriptor.isReady() || descriptor.getOptions() == null)
            sett.setEnabled(false);
        if (descriptor.getStatistics() == null)
            stat.setVisibility(View.INVISIBLE);

    }
    icon.setOnClickListener(new myOnclickListener(myOnclickListener.PLAY,
            GameManager.instance(context).getIndexFor(descriptor), context));
    sett.setOnClickListener(new myOnclickListener(myOnclickListener.SETTINGS,
            GameManager.instance(context).getIndexFor(descriptor), context));
    tutorial.setOnClickListener(new myOnclickListener(myOnclickListener.TUTORIAL,
            GameManager.instance(context).getIndexFor(descriptor), context));
    stat.setOnClickListener(new myOnclickListener(myOnclickListener.STATISTICS,
            GameManager.instance(context).getIndexFor(descriptor), context));
    container.addView(layout);

    return layout;
}

From source file:com.grottworkshop.gwsdrawerdrawableapp.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home_view);/* w  w  w  .  java 2 s .c o  m*/

    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    final ImageView imageView = (ImageView) findViewById(R.id.drawer_indicator);
    final Resources resources = getResources();

    drawerArrowDrawable = new DrawerArrowDrawable(resources);
    drawerArrowDrawable.setStrokeColor(resources.getColor(R.color.light_gray));
    imageView.setImageDrawable(drawerArrowDrawable);

    drawer.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {
        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            offset = slideOffset;

            // Sometimes slideOffset ends up so close to but not quite 1 or 0.
            if (slideOffset >= .995) {
                flipped = true;
                drawerArrowDrawable.setFlip(flipped);
            } else if (slideOffset <= .005) {
                flipped = false;
                drawerArrowDrawable.setFlip(flipped);
            }

            drawerArrowDrawable.setParameter(offset);
        }
    });

    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (drawer.isDrawerVisible(GravityCompat.START)) {
                drawer.closeDrawer(GravityCompat.START);
            } else {
                drawer.openDrawer(GravityCompat.START);
            }
        }
    });

    final TextView styleButton = (TextView) findViewById(R.id.indicator_style);
    styleButton.setOnClickListener(new View.OnClickListener() {
        boolean rounded = false;

        @Override
        public void onClick(View v) {
            styleButton.setText(rounded //
                    ? resources.getString(R.string.rounded) //
                    : resources.getString(R.string.squared));

            rounded = !rounded;

            drawerArrowDrawable = new DrawerArrowDrawable(resources, rounded);
            drawerArrowDrawable.setParameter(offset);
            drawerArrowDrawable.setFlip(flipped);
            drawerArrowDrawable.setStrokeColor(resources.getColor(R.color.light_gray));

            imageView.setImageDrawable(drawerArrowDrawable);
        }
    });
}

From source file:com.heath_bar.tvdb.SeriesOverview.java

/** Populate the interface with the data pulled from the webz */
private void PopulateStuff(TvSeries seriesInfo) {

    if (seriesInfo == null) {
        Toast.makeText(getApplicationContext(), "Something bad happened. No data was found.",
                Toast.LENGTH_SHORT).show();
        return;//from w w  w  . ja  v  a 2  s  .  c o m
    }

    // Set title
    getSupportActionBar().setTitle(seriesInfo.getName());

    // Hide/Activate the favorites button
    if (seriesInfo.isFavorite(getApplicationContext())) {
        Button b = (Button) findViewById(R.id.btn_add_to_favorites);
        b.setVisibility(View.GONE);
    } else {
        Button b = (Button) findViewById(R.id.btn_add_to_favorites);
        b.setVisibility(View.VISIBLE);
        b.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Button b = (Button) findViewById(R.id.btn_add_to_favorites);
                b.setVisibility(View.GONE);
                addToFavorites();
            }
        });
    }

    // Set the banner
    ImageView imageView = (ImageView) findViewById(R.id.series_banner);
    imageView.setImageBitmap(seriesInfo.getImage().getBitmap());
    imageView.setVisibility(View.VISIBLE);
    final String seriesName = seriesInfo.getName();

    imageView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            shareImage();
        }
    });

    // Set the banner link
    TextView textview = (TextView) findViewById(R.id.banner_listing_link);
    textview.setTextColor(getResources().getColor(R.color.tvdb_green));
    textview.setVisibility(View.VISIBLE);
    textview.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent i = new Intent(getApplicationContext(), BannerListing.class);
            i.putExtra("seriesId", seriesId);
            i.putExtra("seriesName", seriesName);
            startActivity(i);
        }
    });

    // Set air info
    textview = (TextView) findViewById(R.id.airs_header);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.last_episode);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.next_episode);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.series_air_info);
    StringBuffer sb = new StringBuffer();
    sb.append(seriesInfo.getAirDay());
    if (!seriesInfo.getAirTime().equals(""))
        sb.append(" at " + seriesInfo.getAirTime());
    if (!seriesInfo.getNetwork().equals(""))
        sb.append(" on " + seriesInfo.getNetwork());
    textview.setText(sb.toString());
    textview.setVisibility(View.VISIBLE);

    // Set actors
    textview = (TextView) findViewById(R.id.starring);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.series_actors);
    textview.setVisibility(View.VISIBLE);

    SpannableStringBuilder text = tagsBuilder(seriesInfo.getActors(), "|");
    textview.setText(text, BufferType.SPANNABLE);
    textview.setMovementMethod(LinkMovementMethod.getInstance());

    // Set rating
    textview = (TextView) findViewById(R.id.rating_header);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.rating);
    textview.setText(seriesInfo.getRating() + " / 10");
    textview.setVisibility(View.VISIBLE);

    // Set genre
    textview = (TextView) findViewById(R.id.genre_header);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.genre);
    textview.setText(StringUtil.commafy(seriesInfo.getGenre()));
    textview.setVisibility(View.VISIBLE);

    // Set runtime
    textview = (TextView) findViewById(R.id.runtime_header);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.runtime);
    textview.setText(seriesInfo.getRuntime() + " minutes");
    textview.setVisibility(View.VISIBLE);

    // Set overview
    textview = (TextView) findViewById(R.id.overview_header);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.overview);
    textview.setText(seriesInfo.getOverview());
    textview.setVisibility(View.VISIBLE);

    // Show Seasons header
    textview = (TextView) findViewById(R.id.seasons_header);
    textview.setVisibility(View.VISIBLE);

    // IMDB Link
    textview = (TextView) findViewById(R.id.imdb_link);
    textview.setVisibility(View.VISIBLE);

    final String imdbId = seriesInfo.getIMDB();
    SpannableStringBuilder ssb = new SpannableStringBuilder(getResources().getString(R.string.imdb));
    ssb.setSpan(new NonUnderlinedClickableSpan(getResources().getString(R.string.imdb)) {
        @Override
        public void onClick(View v) {
            Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.imdb.com/title/" + imdbId));
            startActivity(myIntent);
        }
    }, 0, ssb.length(), 0);

    ssb.setSpan(new TextAppearanceSpan(this, R.style.episode_link), 0, ssb.length(), 0); // Set the style of the text
    textview.setText(ssb, BufferType.SPANNABLE);
    textview.setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:mobi.cangol.mobile.uiframe.demo.Main2Activity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home_view);//  w  w w  .  jav a 2s  .co m

    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    final ImageView imageView = (ImageView) findViewById(R.id.drawer_indicator);
    final Resources resources = getResources();

    drawerArrowDrawable = new DrawerArrowDrawable(resources);
    drawerArrowDrawable.setStrokeColor(resources.getColor(R.color.light_gray));
    imageView.setImageDrawable(drawerArrowDrawable);

    drawer.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {
        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            offset = slideOffset;

            // Sometimes slideOffset ends up so close to but not quite 1 or
            // 0.
            if (slideOffset >= .995) {
                flipped = true;
                drawerArrowDrawable.setFlip(flipped);
            } else if (slideOffset <= .005) {
                flipped = false;
                drawerArrowDrawable.setFlip(flipped);
            }

            drawerArrowDrawable.setParameter(offset);
        }
    });

    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (drawer.isDrawerVisible(START)) {
                drawer.closeDrawer(START);
            } else {
                drawer.openDrawer(START);
            }
        }
    });

    final TextView styleButton = (TextView) findViewById(R.id.indicator_style);
    styleButton.setOnClickListener(new View.OnClickListener() {
        boolean rounded = false;

        @Override
        public void onClick(View v) {
            styleButton.setText(rounded //
                    ? resources.getString(R.string.rounded) //
                    : resources.getString(R.string.squared));

            rounded = !rounded;

            drawerArrowDrawable = new DrawerArrowDrawable(resources, rounded);
            drawerArrowDrawable.setParameter(offset);
            drawerArrowDrawable.setFlip(flipped);
            drawerArrowDrawable.setStrokeColor(resources.getColor(R.color.light_gray));

            imageView.setImageDrawable(drawerArrowDrawable);
        }
    });
}

From source file:com.bt.download.android.gui.adapters.TransferListAdapter.java

private void populatePeerUpload(View view, PeerHttpUpload upload) {
    TextView title = findView(view, R.id.view_transfer_list_item_title);
    ProgressBar progress = findView(view, R.id.view_transfer_list_item_progress);
    TextView status = findView(view, R.id.view_transfer_list_item_status);
    TextView speed = findView(view, R.id.view_transfer_list_item_speed);
    TextView size = findView(view, R.id.view_transfer_list_item_size);
    TextView seeds = findView(view, R.id.view_transfer_list_item_seeds);
    TextView peers = findView(view, R.id.view_transfer_list_item_peers);
    ImageView buttonAction = findView(view, R.id.view_transfer_list_item_button_action);

    seeds.setText("");
    peers.setText("");
    title.setText(upload.getDisplayName());
    progress.setProgress(upload.getProgress());
    status.setText(getStatusFromResId(upload.getStatus()));
    speed.setText(UIUtils.getBytesInHuman(upload.getUploadSpeed()) + "/s");
    size.setText(UIUtils.getBytesInHuman(upload.getSize()));

    buttonAction.setTag(upload);//from   www .j a  v  a 2s. c o  m
    buttonAction.setOnClickListener(viewOnClickListener);
}