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:flex.android.magiccube.welcome.ViewPagerAdapter.java

@Override
public Object instantiateItem(View arg0, int arg1) {
    ((ViewPager) arg0).addView(views.get(arg1), 0);
    if (arg1 == views.size() - 1) {
        ImageView mStartWeiboImageButton = (ImageView) arg0.findViewById(R.id.iv_start_weibo);
        mStartWeiboImageButton.setOnClickListener(new OnClickListener() {

            @Override/*from  w  ww.  j a  va  2 s .c om*/
            public void onClick(View v) {
                // ?
                setGuided();
                goHome();

            }

        });
    }
    return views.get(arg1);
}

From source file:com.me.harris.listviewitemanimations._01_activityAnim.ActivityAnimations.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_animations);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from   ww w  . j a v  a2s.  c  o m*/
    getSupportActionBar().setTitle("");
    handleStatusBar();
    // Grayscale filter used on all thumbnails
    ColorMatrix grayMatrix = new ColorMatrix();
    grayMatrix.setSaturation(0);
    ColorMatrixColorFilter grayscaleFilter = new ColorMatrixColorFilter(grayMatrix);
    mGridLayout = (GridLayout) findViewById(R.id.gridLayout);
    mGridLayout.setColumnCount(3);
    mGridLayout.setUseDefaultMargins(true);
    // add all photo thumbnails to layout
    Resources resources = getResources();
    ArrayList<PictureData> pictures = mBitmapUtils.loadPhotos(resources);
    for (int i = 0; i < pictures.size(); ++i) {
        PictureData pictureData = pictures.get(i);
        BitmapDrawable thumbnailDrawable = new BitmapDrawable(resources, pictureData.thumbnail);
        thumbnailDrawable.setColorFilter(grayscaleFilter);
        ImageView imageView = new ImageView(this);
        imageView.setOnClickListener(thumbnailClickListener);
        imageView.setImageDrawable(thumbnailDrawable);
        mPicturesData.put(imageView, pictureData);
        mGridLayout.addView(imageView);
    }
}

From source file:edu.ucsb.cs.cs185.inspirante.searchbyranking.RankInnerAdapter.java

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

    if (mContext == null) {
        Log.e("mContext", "null");
    }/*  w w  w .ja  v  a  2 s.  c o m*/

    Cards.CardImage cardImage = mCardImages.get(position);
    ImageView imageView = holder.imageView;

    PicassoImageLoader.loadImageToView(mContext, cardImage, imageView, 220, 220);

    imageView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            mFragment.startDetailDialog(mCardImages.get(position));
        }
    });
}

From source file:net.potterpcs.recipebook.PhotoDialog.java

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

    ImageView photo = (ImageView) v.findViewById(R.id.dialogphoto);
    RecipeBook.setImageViewBitmapDecoded(getActivity(), photo, photoUri);

    photo.setOnClickListener(new OnClickListener() {
        @Override/*from  w  w  w  .jav a2 s.c  o m*/
        public void onClick(View clicked) {
            //            Log.i(TAG, "Dismissing dialog");
            dismiss();
        }
    });

    return v;
}

From source file:anakiou.com.picontrol.ui.fragments.MainMenuFragment.java

private void setupInputs(View view) {

    ImageView inputsImage = (ImageView) view.findViewById(R.id.inputs_image);

    inputsImage.setOnClickListener(new View.OnClickListener() {
        @Override// w ww  .  j a  v a  2s .c  o  m
        public void onClick(View v) {
            if (networkService.isNetworkAvailableAndConnected()) {
                Intent intent = InputsActivity.newIntent(getActivity());
                startActivity(intent);
            } else {
                noNetwork();
            }
        }
    });

}

From source file:anakiou.com.picontrol.ui.fragments.MainMenuFragment.java

private void setupOutputs(View view) {

    ImageView outputsImage = (ImageView) view.findViewById(R.id.outputs_image);

    outputsImage.setOnClickListener(new View.OnClickListener() {
        @Override/*ww  w. j  a  va2 s .c  om*/
        public void onClick(View v) {
            if (networkService.isNetworkAvailableAndConnected()) {
                Intent intent = OutputsActivity.newIntent(getActivity());
                startActivity(intent);
            } else {
                noNetwork();
            }
        }
    });
}

From source file:com.axum.darivb.searchview.SlidingTabsBasicFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {

    searchView = (SearchView) view.findViewById(R.id.search_view);
    searchView.setIconified(false);/*from  ww  w .j ava 2s  .c o m*/
    ImageView back = (ImageView) view.findViewById(R.id.imageView);
    back.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            android.app.FragmentManager fm = getFragmentManager();
            fm.popBackStack();
        }
    });

    ViewPager mViewPager = (ViewPager) view.findViewById(R.id.viewpager);
    mViewPager.setAdapter(new SearchPagerAdapter());

    SlidingTabLayout mSlidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tabs);
    mSlidingTabLayout.setViewPager(mViewPager);

    mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {

            searchView.setQueryHint("Search " + tabs[position]);
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

}

From source file:anakiou.com.picontrol.ui.fragments.MainMenuFragment.java

private void setupEditNames(View view) {

    ImageView editNamesImage = (ImageView) view.findViewById(R.id.edit_names_image);

    editNamesImage.setOnClickListener(new View.OnClickListener() {
        @Override/*from   w  w w.  ja va2 s  .co  m*/
        public void onClick(View v) {

            if (networkService.isNetworkAvailableAndConnected()) {
                Intent intent = EditNamesActivity.newIntent(getActivity());
                startActivity(intent);
            } else {
                noNetwork();
            }
        }
    });
}

From source file:com.example.angelina.travelapp.route.RouteDirectionsFragment.java

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

    // Set up the header
    ImageView backBtn = (ImageView) getActivity().findViewById(R.id.btnCloseDirections);
    backBtn.setOnClickListener(new View.OnClickListener() {
        @Override/*from  w ww  .j  a  va  2 s.  c  o m*/
        public void onClick(View v) {
            ((MapActivity) getActivity()).restoreRouteView();
        }
    });

    // Hide the action bar
    final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
    if (ab != null) {
        ab.hide();
    }

    // Setup list adapter
    final ListView listView = (ListView) view.findViewById(R.id.directions_list);
    mAdapter = new DirectionsListAdapter(mDirectionManeuvers);
    listView.setAdapter(mAdapter);

    // When directions are tapped, show selected route section
    // highlighted on map and zoomed in with route section description
    // overlayed on map
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ((MapActivity) getActivity()).showRouteDetail(position);
        }
    });

    return view;
}

From source file:com.xabber.android.ui.adapter.OccupantListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final View view;
    if (convertView == null) {
        view = activity.getLayoutInflater().inflate(R.layout.item_occupant, parent, false);
    } else {/*w w  w . j  a va2 s.co  m*/
        view = convertView;
    }
    final Occupant occupant = (Occupant) getItem(position);
    final ImageView avatarView = (ImageView) view.findViewById(R.id.ivAvatar);
    avatarView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent;
            try {
                intent = ContactActivity.createIntent(activity, account,
                        UserJid.from(JidCreate.domainFullFrom(room.asDomainBareJid(), occupant.getNickname())));
                activity.startActivity(intent);
            } catch (UserJid.UserJidCreateException e) {
                LogManager.exception(this, e);
            }

        }
    });

    final ImageView affilationView = (ImageView) view.findViewById(R.id.affilation);
    final TextView nameView = (TextView) view.findViewById(R.id.name);
    final TextView statusTextView = (TextView) view.findViewById(R.id.status);
    final ImageView statusModeView = (ImageView) view.findViewById(R.id.ivStatus);
    if (MUCManager.getInstance().getNickname(account, room).equals(occupant.getNickname())) {
        avatarView.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
    } else {
        try {
            avatarView.setImageDrawable(
                    AvatarManager.getInstance().getUserAvatar(UserJid.from(occupant.getJid())));
        } catch (UserJid.UserJidCreateException e) {
            LogManager.exception(this, e);
            // set default avatar
            avatarView.setImageDrawable(ContextCompat.getDrawable(parent.getContext(), R.drawable.ic_avatar_1));
        }
    }
    affilationView.setImageLevel(occupant.getAffiliation().ordinal());
    nameView.setText(occupant.getNickname());

    String status;
    if (occupant.getRole() == MUCRole.moderator)
        status = activity.getString(R.string.muc_role_moderator);
    else if (occupant.getRole() == MUCRole.participant)
        status = activity.getString(R.string.muc_role_participant);
    else
        status = activity.getString(R.string.muc_role_visitor);

    String statusText = occupant.getStatusText();
    if (statusText != null && !statusText.isEmpty())
        status = status + "  " + statusText;

    statusTextView.setText(status);
    statusModeView.setImageLevel(occupant.getStatusMode().getStatusLevel());
    return view;
}