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.imalu.alyou.activity.GroupsActivity.java

public void generateList() {
    //      grouplist =   EMGroupManager.getInstance().getAllGroups();
    groupListView = (ListView) findViewById(R.id.list);
    groupAdapter = new GroupAdapter(this, R.layout.row_group,
            AlUApplication.getGroups().getConversationGroupList());
    groupListView.setAdapter(groupAdapter);
    groupListView.setOnItemClickListener(new OnItemClickListener() {

        @Override/* w  w w.j  av a2 s  . c  om*/
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            //            if (position == groupAdapter.getCount() - 1) {
            //               //?
            //               startActivityForResult(new Intent(GroupsActivity.this, NewGroupActivity.class), 0);
            //            } else {

            //?
            Intent intent = new Intent(GroupsActivity.this, ChatActivity.class);
            // it is group chat
            intent.putExtra("chatType", ChatActivity.CHATTYPE_GROUP);
            intent.putExtra("groupId", groupAdapter.getItem(position).getGroupKey());
            intent.putExtra("groupName", groupAdapter.getItem(position).getGroupName());
            startActivityForResult(intent, 0);
            //            }
        }

    });
    groupListView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });

    ImageView addContactView = (ImageView) findViewById(R.id.iv_new_group);
    addContactView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(GroupsActivity.this, NewGroupActivity.class));
        }
    });
}

From source file:io.techministry.android.fellowshipmissionchurch.ui.AnnouncementListFragment.java

private void attachRecyclerViewAdapter() {
    mRecyclerViewAdapter = new FirebaseRecyclerAdapter<Announcement, AnnouncementHolder>(Announcement.class,
            R.layout.adapter_announcement_item, AnnouncementHolder.class, mQuery) {

        @Override/*  w w  w  .ja  v  a 2s. c om*/
        public void populateViewHolder(AnnouncementHolder viewHolder, final Announcement announcement,
                final int position) {
            viewHolder.setData(announcement);

            viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                    if (announcement.getContent_type().equals("video")) {
                        Intent intent = new Intent(context, PlayerActivity.class);
                        intent.putExtra("video_url", announcement.getVideo_url());
                        startActivity(intent);
                    } else {
                        Intent intent = new Intent(context, AnnouncementDetailActivity.class);
                        intent.putExtra("announcement", announcement);
                        startActivity(intent);
                    }

                }
            });

            ImageView imageView = (ImageView) viewHolder.itemView.findViewById(R.id.like);
            imageView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    String unique_id = Utilities.getDeviceID(context);
                    DatabaseReference likeReference = getRef(position).child("likes");
                    DatabaseReference databaseReference = getRef(position);

                    if (FirebaseUtilities.isLiked(context, unique_id, announcement.getLiked())) {
                        FirebaseUtilities.disLikePost(likeReference);
                        databaseReference.child("liked").child(unique_id).setValue(null);
                    } else {
                        FirebaseUtilities.likePost(likeReference);
                        databaseReference.child("liked").child(unique_id).setValue(true);
                    }

                }
            });
        }
    };
    rv.setAdapter(mRecyclerViewAdapter);
}

From source file:MainActivity.java

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

    final ImageView imageViewThumbnail = (ImageView) findViewById(R.id.imageViewThumbnail);
    imageViewThumbnail.setImageBitmap(loadSampledResource(R.drawable.image, 100, 100));
    imageViewThumbnail.setOnClickListener(new View.OnClickListener() {
        @Override//from w w  w.ja  va2  s  .  c  o m
        public void onClick(View view) {
            zoomFromThumbnail((ImageView) view);
        }
    });
    mImageViewExpanded = (ImageView) findViewById(R.id.imageViewExpanded);
    mImageViewExpanded.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mImageViewExpanded.setVisibility(View.GONE);
            mImageViewExpanded.setImageBitmap(null);
            imageViewThumbnail.setVisibility(View.VISIBLE);
        }
    });
}

From source file:com.vinidsl.googleioextended.ui.fragment.SocialFragment.java

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

    ImageView imageViewBig = (ImageView) rootView.findViewById(R.id.imageViewBig);
    ImageView imageViewGplus = (ImageView) rootView.findViewById(R.id.gplus);
    ImageView imageViewTwitter = (ImageView) rootView.findViewById(R.id.twitter);

    imageViewBig.setOnClickListener(this);
    imageViewGplus.setOnClickListener(this);
    imageViewTwitter.setOnClickListener(this);

    return rootView;
}

From source file:com.laevatein.internal.ui.adapter.AlbumPhotoAdapter.java

@Override
public void bindView(View view, final Context context, Cursor cursor) {
    final Item item = Item.valueOf(cursor);

    ImageView thumbnail = (ImageView) view.findViewById(mResources.getImageViewId());
    final CheckBox check = (CheckBox) view.findViewById(mResources.getCheckBoxId());
    thumbnail.setOnClickListener(new View.OnClickListener() {
        @Override/* w  w w  .ja  v a 2  s. c o m*/
        public void onClick(View v) {
            if (item.isCapture()) {
                PhotoGridViewHelper.callCamera(context);
            } else {
                PhotoGridViewHelper.callPreview(context, item, mCollection.asList());
            }
        }
    });
    check.setVisibility(item.isCapture() ? View.GONE : View.VISIBLE);
    check.setChecked(mCollection.isSelected(item.buildContentUri()));
    check.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            PhotoGridViewHelper.syncCheckState(context, mCollection, item, check);
            PhotoGridViewHelper.callCheckStateListener(mListener);
        }
    });
    if (item.isCapture()) {
        thumbnail.setImageResource(R.drawable.l_ic_capture);
    } else {
        Picasso.with(context).load(item.buildContentUri())
                .resizeDimen(R.dimen.l_gridItemImageWidth, R.dimen.l_gridItemImageHeight).centerCrop()
                .into(thumbnail);
    }
    mBindListener.onBindView(context, view, item.buildContentUri());
}

From source file:com.gaba.alex.trafficincidents.Adapter.IncidentsAdapter.java

@Override
public void bindView(View view, final Context context, Cursor cursor) {
    super.bindView(view, context, cursor);

    final int type = cursor.getInt(cursor.getColumnIndexOrThrow(IncidentsColumns.TYPE));
    final int severity = cursor.getInt(cursor.getColumnIndexOrThrow(IncidentsColumns.SEVERITY));
    final double lat = cursor.getDouble(cursor.getColumnIndexOrThrow(IncidentsColumns.LAT));
    final double lng = cursor.getDouble(cursor.getColumnIndexOrThrow(IncidentsColumns.LNG));
    final double toLat = cursor.getDouble(cursor.getColumnIndexOrThrow(IncidentsColumns.TO_LAT));
    final double toLng = cursor.getDouble(cursor.getColumnIndexOrThrow(IncidentsColumns.TO_LNG));
    final long dateInMillis = Long
            .parseLong(cursor.getString(cursor.getColumnIndexOrThrow(IncidentsColumns.END_DATE)));
    final boolean roadClosed = Boolean
            .valueOf(cursor.getString(cursor.getColumnIndexOrThrow(IncidentsColumns.ROAD_CLOSED)));
    final String description = cursor.getString(cursor.getColumnIndexOrThrow(IncidentsColumns.DESCRIPTION));

    TextView typeTextView = (TextView) view.findViewById(R.id.incident_type);
    if (typeTextView != null) {
        typeTextView.setText(Utility.getIncidentType(mContext, type));
    }//from w  w  w .ja v  a2s .  c o m

    TextView severityTextView = (TextView) view.findViewById(R.id.incident_severity);
    if (severityTextView != null) {
        severityTextView.setText(Utility.getIncidentSeverity(mContext, severity));
        severityTextView.setTextColor(ContextCompat.getColor(mContext, Utility.getIncidentColor(severity)));
    }

    TextView roadClosedTextView = (TextView) view.findViewById(R.id.incident_road_closed);
    if (roadClosedTextView != null) {
        roadClosedTextView.setText(String.format("%s: ", mContext.getString(R.string.road_closed)));
    }

    TextView roadClosedContentTextView = (TextView) view.findViewById(R.id.incident_road_closed_content);
    if (roadClosedContentTextView != null) {
        roadClosedContentTextView
                .setText(roadClosed ? mContext.getString(R.string.yes) : mContext.getString(R.string.no));
        roadClosedContentTextView.setTextColor(ContextCompat.getColor(mContext,
                roadClosed ? android.R.color.holo_red_light : android.R.color.holo_green_dark));
    }

    TextView dateTextView = (TextView) view.findViewById(R.id.incident_end_date);
    if (dateTextView != null) {
        dateTextView.setText(String.format("%s: ", mContext.getString(R.string.estimated_end_date)));
    }

    TextView dateContentTextView = (TextView) view.findViewById(R.id.incident_end_date_content);
    if (dateContentTextView != null) {
        dateContentTextView.setText(DateFormat.getDateInstance().format(new Date(dateInMillis)));
    }

    TextView descriptionTextView = (TextView) view.findViewById(R.id.incident_description);
    if (descriptionTextView != null) {
        descriptionTextView.setText(String.format("%s: ", mContext.getString(R.string.local_description)));
    }

    TextView descriptionContentTextView = (TextView) view.findViewById(R.id.incident_description_content);
    if (descriptionContentTextView != null) {
        descriptionContentTextView.setText(description);
    }

    ImageView showOnMapImageView = (ImageView) view.findViewById(R.id.show_on_map_button);
    showOnMapImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = Utility.buildShowOnMapIntent(mContext, lat, lng, toLat, toLng, severity,
                    description);
            if (intent.resolveActivity(mContext.getPackageManager()) != null) {
                mContext.startActivity(intent);
            }
        }
    });

    ImageView shareImageView = (ImageView) view.findViewById(R.id.share_button);
    shareImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("text/plain");
            String shareText = Utility.getIncidentType(mContext, type) + "\n\n"
                    + mContext.getString(R.string.local_description) + ": " + description + "\n\n"
                    + mContext.getString(R.string.severity) + ": "
                    + Utility.getIncidentSeverity(mContext, severity) + "\n\n"
                    + mContext.getString(R.string.road_closed) + ": "
                    + (roadClosed ? mContext.getString(R.string.yes) : mContext.getString(R.string.no)) + "\n\n"
                    + mContext.getString(R.string.provided_by) + ": " + mContext.getString(R.string.app_name);
            intent.putExtra(Intent.EXTRA_TEXT, shareText);
            if (intent.resolveActivity(mContext.getPackageManager()) != null) {
                mContext.startActivity(intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
            }
        }
    });
}

From source file:agronet.mpayer.zegetech.com.mpayercashbox.fragments.HomeMenuFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    switch (position) {
    case 0:/*from  w  w w  .  j  a v a  2 s.  co  m*/
        View view = inflater.inflate(R.layout.fragment_home, container, false);

        TextView tv = (TextView) view.findViewById(R.id.orders);
        tv.setTypeface(Constants.getCustomFace(getActivity(), "Open"));

        ImageView btnOrders = (ImageView) view.findViewById(R.id.ordersBtn);
        btnOrders.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(getActivity(), OrdersActivity.class);
                startActivity(i);
            }
        });
        tv = (TextView) view.findViewById(R.id.transactions);
        tv.setTypeface(Constants.getCustomFace(getActivity(), "Open"));

        ImageView btnTransactions = (ImageView) view.findViewById(R.id.transactionsBtn);
        btnTransactions.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(getActivity(), TransactionsActivity.class);
                startActivity(i);
            }
        });

        tv = (TextView) view.findViewById(R.id.accounts);
        tv.setTypeface(Constants.getCustomFace(getActivity(), "Open"));

        ImageView btnAccounts = (ImageView) view.findViewById(R.id.accountsBtn);
        btnAccounts.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(getActivity(), AccountsActivity.class);
                startActivity(i);
            }
        });

        tv = (TextView) view.findViewById(R.id.members);
        tv.setTypeface(Constants.getCustomFace(getActivity(), "Open"));

        ImageView btnMembers = (ImageView) view.findViewById(R.id.membersBtn);
        btnMembers.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(getActivity(), MembersActivity.class);
                startActivity(i);
            }
        });

        tv = (TextView) view.findViewById(R.id.reports);
        tv.setTypeface(Constants.getCustomFace(getActivity(), "Open"));

        ImageView btnReports = (ImageView) view.findViewById(R.id.reportsBtn);
        btnReports.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(getActivity(), ReportsActivity.class);
                startActivity(i);
            }
        });

        tv = (TextView) view.findViewById(R.id.settings);
        tv.setTypeface(Constants.getCustomFace(getActivity(), "Open"));

        ImageView btnSettings = (ImageView) view.findViewById(R.id.settingsBtn);
        btnSettings.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(getActivity(), SettingsActivity.class);
                startActivity(i);
            }
        });
        return view;
    case 1:
        LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        FrameLayout fl = new FrameLayout(getActivity());

        fl.setLayoutParams(params);

        final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                getResources().getDisplayMetrics());
        TextView v = new TextView(getActivity());
        params.setMargins(margin, margin, margin, margin);
        v.setLayoutParams(params);
        v.setLayoutParams(params);
        v.setGravity(Gravity.CENTER);
        v.setText("LOG");

        fl.addView(v);
        return fl;
    }
    return null;
}

From source file:album.AlbumFragmentMain.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

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

    // Instantiate a ViewPager and a PagerAdapter.
    mPager = (ViewPager) rootView.findViewById(R.id.pager);

    mPagerAdapter = new ScreenSlidePagerAdapter(getChildFragmentManager());
    mPager.setAdapter(mPagerAdapter);/*from  w w  w . j  a  va2  s  .  co  m*/
    mPager.setOffscreenPageLimit(2);

    ImageView returnButton = (ImageView) rootView.findViewById(R.id.imageView3);
    returnButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mPager.setCurrentItem(getItem(-1), true); //getItem(-1) for previous
        }
    });

    ImageView forwardButton = (ImageView) rootView.findViewById(R.id.imageView4);
    forwardButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mPager.setCurrentItem(getItem(+1), true); //getItem(-1) for previous
        }
    });
    return rootView;
}

From source file:com.wenwen.chatuidemo.activity.ContactlistFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    DebugLog.i(TAG, "onActivityCreated");
    inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    listView = (ListView) getView().findViewById(R.id.list);
    contactList = new ArrayList<MyUser>();
    // ?contactlist
    getContactList();//from   ww w  . j av  a 2  s  .  c  o  m
    // adapter
    listView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            startActivity(new Intent(getActivity(), ColleaguesInfo.class).putExtra("uid",
                    contactList.get(position).getAccount_id()));
        }
    });

    ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact);
    // ?
    addContactView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            //startActivity(new Intent(getActivity(), AddContactActivity.class));
            startActivityForResult(new Intent(getActivity(), AddContactActivity.class),
                    Constants.ActionCode.ACT_FIND);
        }
    });
}

From source file:com.perm.DoomPlay.SearchVkActivity.java

private void initializeUi() {
    editQuery = (EditText) findViewById(R.id.editQuery);
    listView = (ListView) findViewById(R.id.listSearch);
    ImageView buttonSearch = (ImageView) findViewById(R.id.imageSearchVk);
    buttonSearch.setOnClickListener(onClickSearch);
    listView.setOnItemClickListener(onItemTrackClick);

    listView.setOnItemLongClickListener(onItemLongVkListener);
    linearControls = (RelativeLayout) findViewById(R.id.linearControls);
    intentService = new Intent(this, PlayingService.class);
    intentService.setAction(PlayingService.actionOnline);
    imgPlay = (ImageView) findViewById(R.id.imagePlay);
    imgShuffle = (ImageView) findViewById(R.id.imageShuffle);
    imgRepeat = (ImageView) findViewById(R.id.imageRepeat);
    imgNext = (ImageView) findViewById(R.id.imageNext);
    imgPrevious = (ImageView) findViewById(R.id.imagePrevious);
    seekBar = (SeekBar) findViewById(R.id.seek_bar);
    textCurrentTime = (TextView) findViewById(R.id.textElapsed);
    textTotalTime = (TextView) findViewById(R.id.textDuration);
    linearLoading = (LinearLayout) findViewById(R.id.linearLoading);
}