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.siva.animation_sample.HomeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    //getActionBar().setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
    getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    getActionBar().setDisplayShowCustomEnabled(true);
    getActionBar().setCustomView(R.layout.custom_action_bar_layout);
    custom_action_view = getActionBar().getCustomView();
    ImageView more_icon = (ImageView) custom_action_view.findViewById(R.id.moreimage);
    more_icon.setOnClickListener(new View.OnClickListener() {

        @Override/*  www  . j  ava 2s .c om*/
        public void onClick(View v) {
            // TODO Auto-generated method stub
            PopupMenu popup = new PopupMenu(HomeActivity.this, v);
            MenuInflater inflate = popup.getMenuInflater();
            inflate.inflate(R.menu.home, popup.getMenu());
            popup.show();
            popup.setOnMenuItemClickListener(HomeActivity.this);

        }
    });

    mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup(this, getSupportFragmentManager(), android.R.id.tabcontent);
    Create_alert_box();

    mTabHost.addTab(
            mTabHost.newTabSpec("tab1").setIndicator(null, getResources().getDrawable(R.drawable.ic_launcher)),
            FragmentTab1.class, null);
    mTabHost.addTab(
            mTabHost.newTabSpec("tab2").setIndicator(null, getResources().getDrawable(R.drawable.ic_launcher)),
            FragmentTab2.class, null);
    mTabHost.addTab(
            mTabHost.newTabSpec("tab3").setIndicator(null, getResources().getDrawable(R.drawable.ic_launcher)),
            FragmentTab3.class, null);
    mTabHost.addTab(
            mTabHost.newTabSpec("tab4").setIndicator(null, getResources().getDrawable(R.drawable.ic_launcher)),
            FragmentTab4.class, null);
    mTabHost.addTab(
            mTabHost.newTabSpec("tab5").setIndicator(null, getResources().getDrawable(R.drawable.ic_launcher)),
            FragmentTab5.class, null);

    mTabHost.setCurrentTab(2);

}

From source file:fm.smart.r1.activity.ItemActivity.java

static void setSound(ImageView sound_icon, final String sound_url, final Context context, final int type_id,
        final String artifact_id, final String to_record) {
    if (!TextUtils.isEmpty(sound_url)) {
        OnClickListener sound_listener = new OnClickListener() {
            public void onClick(View v) {
                Main.playSound(sound_url, ItemListActivity.mMediaPlayer, context);
            }//from  w w w  .  j  a v  a  2s. c om
        };
        sound_icon.setOnClickListener(sound_listener);
    } else {
        if (type_id == R.id.response_sound || type_id == R.id.translation_sound) {
            sound_icon.setVisibility(View.INVISIBLE);
        } else {
            sound_icon.setImageBitmap(
                    BitmapFactory.decodeResource(context.getResources(), R.drawable.inactive_sound_add));

            OnClickListener listener = new OnClickListener() {
                public void onClick(View v) {
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setClassName(context, CreateSoundActivity.class.getName());
                    Utils.putExtra(intent, "item_id", (String) item.item_node.atts.get("id"));
                    Utils.putExtra(intent, "to_record", to_record);
                    Utils.putExtra(intent, "id", artifact_id);
                    Utils.putExtra(intent, "sound_type", Integer.toString(type_id));
                    context.startActivity(intent);

                }
            };
            sound_icon.setOnClickListener(listener);
        }
    }
}

From source file:com.euphor.paperpad.activities.main.ScreenSlideActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_screen_slide);
    getActionBar().hide();/*from w w  w  . j  a va2s  . c  o  m*/
    realm = Realm.getInstance(getApplicationContext());
    Bundle receive = getIntent().getExtras();
    id_album = receive.getInt("id_album");
    id_illustration = receive.getInt("id_illustration");

    album = realm.where(Album.class).equalTo("id_album", id_album).findFirst();
    //appController.getAlbumDao().queryForId(id_album);

    ImageView close_picture = (ImageView) findViewById(R.id.close_picture);
    close_picture.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();

        }
    });

    illustrations = new ArrayList<Illustration>();
    for (Iterator<Photo> iterator = album.getPhotos().iterator(); iterator.hasNext();) {
        Photo photo = (Photo) iterator.next();
        //if (photo.getIllustration().getOriginalHeight()>0) {
        illustrations.add(photo.getIllustration());
        //}

    }

    Illustration item2 = null;
    item2 = realm.where(Illustration.class).equalTo("id_i", id_illustration).findFirst();
    //appController.getIllustrationDao().queryForId(id_illustration);
    makeItemFirst(item2);
    // Instantiate a ViewPager and a PagerAdapter.
    mPager = (ViewPager) findViewById(R.id.pager);
    mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
    mPager.setAdapter(mPagerAdapter);
    //        mIndicator = (LinePageIndicator)findViewById(R.id.indicator);
    //        mIndicator.setViewPager(mPager);
    mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When changing pages, reset the action bar actions since they are dependent
            // on which page is currently active. An alternative approach is to have each
            // fragment expose actions itself (rather than the activity exposing actions),
            // but for simplicity, the activity provides the actions in this sample.
            invalidateOptionsMenu();
        }
    });
}

From source file:com.hivewallet.androidclient.wallet.ui.WalletAddressDialogFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    address = getArguments().getString(KEY_ADDRESS);
    final Bitmap qrCode = (Bitmap) getArguments().getParcelable(KEY_QR_CODE);

    final Dialog dialog = new Dialog(activity);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.wallet_address_dialog);
    dialog.setCanceledOnTouchOutside(true);

    final ImageView imageView = (ImageView) dialog.findViewById(R.id.iv_qr_code);
    imageView.setImageBitmap(qrCode);//from  ww w .  j a  va 2 s. c  om
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            dismiss();
        }
    });

    final TextView textView = (TextView) dialog.findViewById(R.id.tv_bitcoin_address);
    textView.setText(address);

    final ImageButton copyButton = (ImageButton) dialog.findViewById(R.id.ib_copy_wallet_address);
    copyButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            handleCopy();
        }
    });

    final ImageButton shareButton = (ImageButton) dialog.findViewById(R.id.ib_share_wallet_address);
    shareButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            handleShare();
        }
    });

    return dialog;
}

From source file:br.com.iworkout.dialog.SerieDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.choose_serie, container, false);
    repeticoes = (EditText) v.findViewById(R.id.repiticoes);
    serie = (EditText) v.findViewById(R.id.serie);
    peso = (EditText) v.findViewById(R.id.peso);
    TextView musculo = (TextView) v.findViewById(R.id.musculo);
    TextView exercicio = (TextView) v.findViewById(R.id.exercicio);

    //        InputFilter[] filter = new InputFilter[]{new InputFilterMinMax("1", "12")};
    //        et.setFilters();
    //        et.setFilters(new InputFilter[]{ new InputFilterMinMax("1", "12")});
    //        et.setFilters(new InputFilter[]{ new InputFilterMinMax("1", "12")});

    musculo.setText(getArguments().getString("musculo") + " -");
    exercicio.setText(getArguments().getString("exercicio"));

    // watch for button clicks.
    ImageView repeatDecrease = (ImageView) v.findViewById(R.id.repeatDecrease);
    repeatDecrease.setOnClickListener(createClickListener());
    ImageView repeatIncrease = (ImageView) v.findViewById(R.id.repeatIncrease);
    repeatIncrease.setOnClickListener(createClickListener());

    ImageView serieIncrease = (ImageView) v.findViewById(R.id.serieIncrease);
    serieIncrease.setOnClickListener(createClickListener());
    ImageView serieDecrease = (ImageView) v.findViewById(R.id.serieDecrease);
    serieDecrease.setOnClickListener(createClickListener());

    ImageView pesoIncrease = (ImageView) v.findViewById(R.id.pesoIncrease);
    pesoIncrease.setOnClickListener(createClickListener());
    ImageView pesoDecrease = (ImageView) v.findViewById(R.id.pesoDecrease);
    pesoDecrease.setOnClickListener(createClickListener());

    Button ok = (Button) v.findViewById(R.id.ok);
    ok.setOnClickListener(new View.OnClickListener() {
        @Override/*from  w w w .  j  a v a2s. co  m*/
        public void onClick(View view) {
            mListener.onDialogPositiveClick(SerieDialog.this, repeticoes, serie, peso);
        }
    });

    Button cancel = (Button) v.findViewById(R.id.cancel);
    cancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mListener.onDialogNegativeClick(SerieDialog.this);
        }
    });
    return v;
}

From source file:com.frostwire.android.gui.adapters.PeerListAdapter.java

@Override
protected void populateView(View view, Peer peer) {
    TextView title = findView(view, R.id.view_peer_list_item_title);
    title.setText(peer.isLocalHost() ? view.getResources().getString(R.string.my_files) : peer.getNickname());

    TextView version = findView(view, R.id.view_peer_list_item_version);
    version.setText("v. " + peer.getClientVersion());
    version.setTextColor(0xffcccccc);//from   w w  w .j av  a  2  s .c  om

    ImageView icon = findView(view, R.id.view_peer_list_item_icon);
    populateIcon(icon, peer);

    ImageView howtoShareButton = findView(view, R.id.view_peer_list_item_button_how_to_share);
    howtoShareButton.setOnClickListener(howtoShareClickListener);

    if (!peer.isLocalHost()) {
        howtoShareButton.setVisibility(View.INVISIBLE);
        title.setTextColor(0xff3b3b3b);
    } else {
        title.setTextColor(0xff54afe4);

        // show my version in red If I'm old to encourage user to update.
        if (SoftwareUpdater.instance().isOldVersion()) {
            version.setTextColor(Color.RED);
            version.setText(getContext().getString(R.string.please_update_to_v,
                    SoftwareUpdater.instance().getLatestVersion()));
        }

        howtoShareButton.setVisibility(View.VISIBLE);
        howtoShareButton.setImageResource(R.drawable.share_howto);
    }

    TextView summary = findView(view, R.id.view_peer_list_item_summary);
    summary.setText(getContext().getString(R.string.summary_files_shared, peer.getNumSharedFiles()));
}

From source file:joshuatee.wx.SPCFragment.java

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

    View view = inflater.inflate(R.layout.fragment_spc, container, false);

    DisplayMetrics dm = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);

    ImageView iv_1 = (ImageView) view.findViewById(R.id.iv_1);
    iv_1.setOnClickListener(this);
    ImageView iv_2 = (ImageView) view.findViewById(R.id.iv_2);
    iv_2.setOnClickListener(this);
    ImageView iv_3 = (ImageView) view.findViewById(R.id.iv_3);
    iv_3.setOnClickListener(this);
    ImageView iv_4 = (ImageView) view.findViewById(R.id.iv_4);
    iv_4.setOnClickListener(this);
    ImageView iv_5 = (ImageView) view.findViewById(R.id.iv_5);
    iv_5.setOnClickListener(this);
    ImageView iv_6 = (ImageView) view.findViewById(R.id.iv_6);
    iv_6.setOnClickListener(this);

    ImageView iv_7 = (ImageView) view.findViewById(R.id.iv_7);
    ImageView iv_8 = (ImageView) view.findViewById(R.id.iv_8);
    ImageView iv_9 = (ImageView) view.findViewById(R.id.iv_9);
    ImageView iv_10 = (ImageView) view.findViewById(R.id.iv_10);
    ImageView iv_11 = (ImageView) view.findViewById(R.id.iv_11);
    ImageView iv_12 = (ImageView) view.findViewById(R.id.iv_12);

    iv_7.setOnClickListener(this);
    iv_8.setOnClickListener(this);
    iv_9.setOnClickListener(this);
    iv_10.setOnClickListener(this);
    iv_11.setOnClickListener(this);
    iv_12.setOnClickListener(this);

    LayoutParams params_iv = null;//from www  . j  a  v a2s  .  c  om
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.meso), iv_1, 3, params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.tstorm), iv_2, 3,
            params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.day1), iv_3, 3, params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.day2), iv_4, 3, params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.day3), iv_5, 3, params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.day48), iv_6, 3, params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.report_today), iv_7, 3,
            params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.report_yesterday), iv_8, 3,
            params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.mcd_tile), iv_9, 3,
            params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.wat), iv_10, 3, params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.spc_sum), iv_11, 3,
            params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.fire_outlook), iv_12, 3,
            params_iv);

    return view;
}

From source file:com.liferay.alerts.activity.CommentsActivity.java

@Override
public void onCreate(Bundle state) {
    super.onCreate(state);

    setContentView(R.layout.comments);/*from w  w w  .  j a  v a 2s.c  om*/

    _alert = getIntent().getExtras().getParcelable(EXTRA_ALERT);

    TextView message = (TextView) findViewById(R.id.message);
    message.setText(_alert.getMessage());

    setBackListener();

    User user = _alert.getUser(this);
    TextView userName = (TextView) findViewById(R.id.user_name);
    ImageView portrait = (ImageView) findViewById(R.id.portrait);
    PortraitUtil.setUserDetails(this, user, portrait, userName);

    _edit = (EditText) findViewById(R.id.edit);

    ImageView post = (ImageView) findViewById(R.id.post);
    post.setOnClickListener(this);

    _registerBroadcastReceiver();

    AsyncTaskCallback callback = new FetchCommentsCallback(getApplicationContext());

    Session session = SettingsUtil.getSession(callback);

    PushnotificationsentryService service = new PushnotificationsentryService(session);

    try {
        service.getPushNotificationsEntries(_alert.getId(), 0, -1, -1);
    } catch (Exception e) {
        ToastUtil.show(this, e.getMessage());
    }
}

From source file:com.cpd.activities.NewsOpenActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_news_open);

    if (getResources().getBoolean(R.bool.portrait_only)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    } else {/*ww w.  j  av a 2s . c o  m*/
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
    }

    Intent intent = getIntent();
    mNewsVo = (NewsVo) intent.getSerializableExtra(AppTags.NEWS_VO);

    TrackerUtils.clickNewsArticle(mNewsVo.title);

    final TextView articleTextView = (TextView) findViewById(R.id.news_activity_text);

    mLoader = new NewsLoader(new NewsParser.NewsReady() {
        @Override
        public void OnNewsReady(NewsVo newsArticle) {
            mConnectionTries++;
            /* Avoid infinite loop */
            if (mConnectionTries <= ConnectionUtils.MAX_NETWORK_TENTATIVES) {
                if (newsArticle.articleText == null) {
                    mLoader.run(mNewsVo, true);
                } else {
                    // Interpret HTML tags
                    mConnectionTries = 0;
                    articleTextView.setText(Html.fromHtml(newsArticle.articleText));
                    articleTextView.setMovementMethod(LinkMovementMethod.getInstance());
                    if (DebugUtils.DEBUG)
                        Log.d(TAG, "Opened article: " + newsArticle.title);
                }
            } else {
                if (DebugUtils.ERROR)
                    Log.e(TAG, "Not connecting to news!");
            }
        }
    });
    mLoader.run(mNewsVo, true);

    // The RssParser already gives the title and image. Therefore, we can load this content
    // while the NewsParser is running.
    Toolbar toolbar = (Toolbar) findViewById(R.id.news_open_toolbar);
    setSupportActionBar(toolbar);

    ImageView imageView = (ImageView) findViewById(R.id.news_activity_picture);
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            openImageActivity();
        }
    });
    Picasso.with(this).load(mNewsVo.imgLargeUrl).into(imageView);

    TextView titleView = (TextView) findViewById(R.id.news_activity_title);
    titleView.setText(mNewsVo.title);

}

From source file:com.zapp.library.merchant.ui.fragment.PBBAPopup.java

@Override
public void onViewCreated(final View view, final Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final ImageView closePopupButton = (ImageView) view.findViewById(R.id.pbba_popup_close);
    if (closePopupButton != null) {
        closePopupButton.setOnClickListener(new View.OnClickListener() {
            @Override//from  www .j  a v  a2s. c  o m
            public void onClick(final View v) {
                dismissWithCallback();
            }
        });
    }
    final View whatIsPayByBankAppLink = view.findViewById(R.id.pbba_link_what_is_pay_by_bank_app);
    if (whatIsPayByBankAppLink != null) {
        whatIsPayByBankAppLink.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                try {
                    final Intent myIntent = new Intent(Intent.ACTION_VIEW,
                            Uri.parse(WHAT_IS_PAY_BY_BANK_APP_LINK));
                    startActivity(myIntent);
                } catch (ActivityNotFoundException ignored) {
                    //no web browser installed, ignore the error
                    Log.w(PBBALibraryUtils.PBBA_LOG_TAG,
                            "Cannot start 'What is Pay by Bank app' link: no browser installed?");
                }
            }
        });
    }
}