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.nanostuffs.yurdriver.fragment.BankDetails.java

private void actionBarDetails() {
    getActivity().getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    final View addView = getActivity().getLayoutInflater().inflate(R.layout.my_custom_navigation, null);

    TextView title = (TextView) addView.findViewById(R.id.title);
    title.setText("REGISTRATION");
    ImageView back = (ImageView) addView.findViewById(R.id.back);
    back.setOnClickListener(new OnClickListener() {

        @Override/*from  www .  jav a2  s .  c o m*/
        public void onClick(View v) {
            // TODO Auto-generated method stub
            FragmentManager manager = getActivity().getSupportFragmentManager();
            manager.popBackStack();
        }
    });
    getActivity().getActionBar().setCustomView(addView);
}

From source file:fr.enseirb.odroidx.remote_client.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    serviceConnection = new CommunicationServiceConnection(this);

    // loading view components
    buttons_layout = (LinearLayout) findViewById(R.id.buttons_layout);
    button_play = (ImageView) findViewById(R.id.button_play);
    button_pause = (ImageView) findViewById(R.id.button_pause);
    button_stop = (ImageView) findViewById(R.id.button_stop);
    button_previous = (ImageView) findViewById(R.id.button_previous);
    button_next = (ImageView) findViewById(R.id.button_next);
    button_up = (ImageView) findViewById(R.id.button_up);
    button_down = (ImageView) findViewById(R.id.button_down);
    button_left = (ImageView) findViewById(R.id.button_left);
    button_right = (ImageView) findViewById(R.id.button_right);
    button_select = (ImageView) findViewById(R.id.button_select);
    button_back = (ImageView) findViewById(R.id.button_back);
    button_home = (ImageView) findViewById(R.id.button_home);
    button_sound_mute = (ImageView) findViewById(R.id.button_sound_mute);
    button_sound_plus = (ImageView) findViewById(R.id.button_sound_plus);
    button_sound_minus = (ImageView) findViewById(R.id.button_sound_minus);
    button_enter_text = (ImageView) findViewById(R.id.button_enter_text);

    // setting listeners
    buttons = new ArrayList<ImageView>();
    buttons.add(button_play);// w  w  w .  java 2s.  c  om
    buttons.add(button_pause);
    buttons.add(button_stop);
    buttons.add(button_previous);
    buttons.add(button_next);
    buttons.add(button_up);
    buttons.add(button_down);
    buttons.add(button_left);
    buttons.add(button_right);
    buttons.add(button_select);
    buttons.add(button_back);
    buttons.add(button_home);
    buttons.add(button_sound_mute);
    buttons.add(button_sound_plus);
    buttons.add(button_sound_minus);
    buttons.add(button_enter_text);

    for (ImageView iv : buttons) {
        iv.setOnClickListener(this);
    }

    buttons_layout.setVisibility(View.GONE);
}

From source file:de.tudarmstadt.informatik.secuso.phishedu2.SwipeActivity.java

void updateUI(Activity v) {
    super.updateUI(v);

    final ViewPager mPager = (ViewPager) v.findViewById(R.id.pager);
    mPager.setAdapter(new SwipePageAdapter(getFragmentManager(), this));
    mPager.setOnPageChangeListener(this);

    ImageView imgPrevious = (ImageView) v.findViewById(R.id.game_intro_arrow_back);
    imgPrevious.setOnClickListener(new OnClickListener() {
        @Override//  www.  j a  va2s  .  c om
        public void onClick(View v) {
            mPager.setCurrentItem(mPager.getCurrentItem() - 1);
        }
    });
    imgPrevious.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            mPager.setCurrentItem(0);
            return true;
        }
    });
    ImageView imgNext = (ImageView) v.findViewById(R.id.game_intro_arrow_forward);
    imgNext.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mPager.setCurrentItem(mPager.getCurrentItem() + 1);
        }
    });
    imgNext.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            mPager.setCurrentItem(getPageCount() - 1);
            return true;
        }
    });

    Button bStartLevel = (Button) v.findViewById(R.id.game_intro_start_button);
    bStartLevel.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            onStartClick();
        }
    });
    bStartLevel.setText(this.startButtonText());

    checkAndHideButtons(0);
}

From source file:com.angui.exam.widget.IconPageIndicator.java

public void notifyDataSetChanged() {
    mIconsLayout.removeAllViews();/*from   w ww.  ja va 2  s  . com*/
    IconPagerAdapter iconAdapter = (IconPagerAdapter) mViewPager.getAdapter();
    int count = iconAdapter.getCount();
    for (int i = 0; i < count; i++) {
        ImageView view = new ImageView(getContext(), null, R.attr.vpiIconPageIndicatorStyle);
        view.setImageResource(iconAdapter.getIconResId(i));
        final int j = i;
        view.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                setCurrentItem(j);
            }
        });
        mIconsLayout.addView(view);
    }
    if (mSelectedIndex > count) {
        mSelectedIndex = count - 1;
    }
    setCurrentItem(mSelectedIndex);
    requestLayout();
}

From source file:com.frostwire.android.gui.activities.internal.NavigationMenu.java

private NavigationView initNavigationView(final MainActivity activity) {
    NavigationView resultNavView = navView;
    if (navView == null) {
        resultNavView = activity.findViewById(R.id.activity_main_nav_view);
        resultNavView.setNavigationItemSelectedListener(menuItem -> {
            onMenuItemSelected(menuItem);
            return true;
        });/*www.ja  v  a 2  s  .  c om*/
        View navViewHeader = resultNavView.getHeaderView(0);
        // Logo
        ImageView navLogo = navViewHeader.findViewById(R.id.nav_view_header_main_app_logo);
        navLogo.setOnClickListener(v -> UIUtils.openURL(v.getContext(), Constants.FROSTWIRE_GIVE_URL));

        // Prep title and version
        TextView title = navViewHeader.findViewById(R.id.nav_view_header_main_title);
        TextView version = navViewHeader.findViewById(R.id.nav_view_header_main_version);
        String basicOrPlus = (String) activity
                .getText(Constants.IS_GOOGLE_PLAY_DISTRIBUTION ? R.string.basic : R.string.plus);
        boolean isDevelopment = Constants.IS_BASIC_AND_DEBUG;
        if (isDevelopment) {
            basicOrPlus = "Developer";
        }
        title.setText("FrostWire " + basicOrPlus);
        version.setText(" v" + Constants.FROSTWIRE_VERSION_STRING);
        TextView build = navViewHeader.findViewById(R.id.nav_view_header_main_build);
        build.setText(activity.getText(R.string.build) + " " + BuildConfig.VERSION_CODE);
        View.OnClickListener aboutActivityLauncher = v -> {
            Intent intent = new Intent(v.getContext(), AboutActivity.class);
            v.getContext().startActivity(intent);
        };
        title.setOnClickListener(aboutActivityLauncher);
        version.setOnClickListener(aboutActivityLauncher);
        build.setOnClickListener(aboutActivityLauncher);

        // Prep update button
        ImageView updateButton = navViewHeader.findViewById(R.id.nav_view_header_main_update);
        updateButton.setVisibility(View.GONE);
        updateButton.setOnClickListener(v -> onUpdateButtonClicked(activity));
    }
    return resultNavView;
}

From source file:com.bangz.shotrecorder.RecordDetailActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.record_detail);

    final Intent intent = getIntent();

    final String action = intent.getAction();

    if (Intent.ACTION_EDIT.equals(action)) {

        mUri = intent.getData();/*from ww  w .ja  v  a 2  s.c  o  m*/

    } else {
        Log.e(TAG, "Unknown Action, exiting");
        finish();
        return;
    }

    ActionBar bar = getSupportActionBar();
    bar.setDisplayHomeAsUpEnabled(true);

    ImageView imageView = (ImageView) findViewById(R.id.imgEditDescript);
    imageView.setOnClickListener(this);

    FragmentManager fm = getSupportFragmentManager();
    SplitListFragment splitfragment = (SplitListFragment) fm.findFragmentById(R.id.splitlist);
    mSplitAdapter = new SplitArrayAdapter(this, mManager.getSplits());
    splitfragment.setListAdapter(mSplitAdapter);

    LoaderManager lm = getSupportLoaderManager();
    lm.initLoader(1, null, this);
}

From source file:au.com.wallaceit.reddinator.ViewAllSubredditsActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    global = ((GlobalObjects) getApplicationContext());
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }/*from   www .  j a v a  2s  . c  om*/
    setContentView(R.layout.viewallsubreddit);
    // setup list view
    listview = getListView();
    listview.setTextFilterEnabled(true);
    listview.setEmptyView(findViewById(R.id.subredditload));
    listview.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent(); // update subreddit without adding to list
            intent.putExtra("subreddit", sreddits.get(position));
            setResult(RESULT_SET_SUBREDDIT, intent);
            finish();
        }
    });
    // get empty view text for easy access later
    emptyview = (TextView) findViewById(R.id.poploadtxt);
    // setup search buttons
    searchbox = (EditText) this.findViewById(R.id.searchbox);
    searchbox.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP) {
                search(v.getText().toString());
            }
            return true;
        }

    });
    ImageView searchbtn = (ImageView) this.findViewById(R.id.searchbutton);
    searchbtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            String query = searchbox.getText().toString();
            if (!query.equals("")) {
                search(query);
            } else {
                new AlertDialog.Builder(ViewAllSubredditsActivity.this).setTitle("No Query")
                        .setMessage("Please enter something to search for").show();
            }
        }
    });
}

From source file:com.runye.express.chat.activity.ContactlistFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    listView = (ListView) getView().findViewById(R.id.list);
    sidebar = (Sidebar) getView().findViewById(R.id.sidebar);
    sidebar.setListView(listView);/*from ww  w.  j a va2 s  . co  m*/
    contactList = new ArrayList<User>();
    // ?contactlist
    getContactList();
    // adapter
    adapter = new ContactAdapter(getActivity(), R.layout.chat_row_contact, contactList, sidebar);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String username = adapter.getItem(position).getUsername();
            if (Constant.NEW_FRIENDS_USERNAME.equals(username)) {
                // ?
                User user = MyApplication.getInstance().getContactList().get(Constant.NEW_FRIENDS_USERNAME);
                user.setUnreadMsgCount(0);
                startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class));
            } else if (Constant.GROUP_USERNAME.equals(username)) {
                // ??
                startActivity(new Intent(getActivity(), GroupsActivity.class));
            } else {
                // demo??
                startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId",
                        adapter.getItem(position).getUsername()));
            }
        }
    });

    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));
        }
    });
    registerForContextMenu(listView);

}

From source file:com.ysls.imhere.fragment.ContactlistFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    listView = (ListView) getView().findViewById(R.id.list);
    sidebar = (Sidebar) getView().findViewById(R.id.sidebar);
    sidebar.setListView(listView);//from w w  w. ja  v  a 2  s.c  o m
    contactList = new ArrayList<User>();
    // ?contactlist
    getContactList();
    // adapter
    adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList, sidebar);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String username = adapter.getItem(position).getUsername();
            if (Constants.NEW_FRIENDS_USERNAME.equals(username)) {
                // ??
                User user = MyApplication.getInstance().getContactList().get(Constants.NEW_FRIENDS_USERNAME);
                user.setUnreadMsgCount(0);
                startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class));
            } else if (Constants.GROUP_USERNAME.equals(username)) {
                // ??
                startActivity(new Intent(getActivity(), GroupsActivity.class));
            } else {
                // demo??
                startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId",
                        adapter.getItem(position).getUsername()));
            }
        }
    });

    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));
        }
    });
    registerForContextMenu(listView);

}

From source file:de.dreier.mytargets.features.training.standardround.StandardRoundListFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.search, menu);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setOnQueryTextListener(this);
    ImageView closeButton = (ImageView) searchView.findViewById(R.id.search_close_btn);
    // Set on click listener
    closeButton.setOnClickListener(v -> {
        EditText et = (EditText) searchView.findViewById(R.id.search_src_text);
        et.setText("");
        searchView.setQuery("", false);
        searchView.onActionViewCollapsed();
        searchItem.collapseActionView();
    });/*from  w  w  w.  j a  va  2s. com*/
}