List of usage examples for android.widget ImageView setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.shollmann.igcparser.ui.activity.IGCFilesActivity.java
@Override public boolean onCreateOptionsMenu(final Menu menu) { getMenuInflater().inflate(R.menu.files_menu, menu); MenuItem menuSearchEntireSdCard = menu.findItem(R.id.menu_search_sdcard); MenuItem menuRefresh = menu.findItem(R.id.menu_refresh); MenuItem menuAbout = menu.findItem(R.id.menu_about); MenuItem menuShare = menu.findItem(R.id.menu_share); MenuItem menuSettings = menu.findItem(R.id.menu_settings); ImageView viewAttach = (ImageView) menu.findItem(R.id.menu_sort).getActionView(); viewAttach.setBackgroundResource(R.drawable.drawable_sort_icon); viewAttach.setOnClickListener(new View.OnClickListener() { @Override//from w w w . j a v a 2 s.c om public void onClick(View v) { showSortDialog(v); } }); menuSearchEntireSdCard.setOnMenuItemClickListener(this); menuRefresh.setOnMenuItemClickListener(this); menuAbout.setOnMenuItemClickListener(this); menuShare.setOnMenuItemClickListener(this); menuSettings.setOnMenuItemClickListener(this); return super.onCreateOptionsMenu(menu); }
From source file:cn.kangeqiu.kq.activity.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;/* w w w .j av a2 s .c om*/ inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(R.id.list); sidebar = (Sidebar) getView().findViewById(R.id.sidebar); sidebar.setListView(listView); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); contactList = new ArrayList<User>(); // ?contactlist getContactList(); //? query = (EditText) getView().findViewById(R.id.query); String strSearch = getResources().getString(R.string.search); query.setHint(strSearch); clearSearch = (ImageButton) getView().findViewById(R.id.search_clear); query.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); if (s.length() > 0) { clearSearch.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.INVISIBLE); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query.getText().clear(); } }); // adapter adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList); 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 = BaseApplication.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())); } } }); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); 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:itkach.aard2.SettingsListAdapter.java
private View getUserStylesView(View convertView, final ViewGroup parent) { View view;//w ww . j a v a 2 s . com LayoutInflater inflater = (LayoutInflater) parent.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); if (convertView != null) { view = convertView; } else { this.userStyleData = userStylePrefs.getAll(); this.userStyleNames = new ArrayList<String>(this.userStyleData.keySet()); Collections.sort(this.userStyleNames); view = inflater.inflate(R.layout.settings_user_styles_item, parent, false); ImageView btnAdd = (ImageView) view.findViewById(R.id.setting_btn_add_user_style); btnAdd.setImageDrawable(FontIconDrawable.inflate(context, R.xml.ic_list_add)); btnAdd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); intent.setType("text/*"); Intent chooser = Intent.createChooser(intent, "Select CSS file"); try { fragment.startActivityForResult(chooser, CSS_SELECT_REQUEST); } catch (ActivityNotFoundException e) { Log.d(TAG, "Not activity to get content", e); Toast.makeText(context, R.string.msg_no_activity_to_get_content, Toast.LENGTH_LONG).show(); } } }); } ; View emptyView = view.findViewById(R.id.setting_user_styles_empty); emptyView.setVisibility(userStyleNames.size() == 0 ? View.VISIBLE : View.GONE); LinearLayout userStyleListLayout = (LinearLayout) view.findViewById(R.id.setting_user_styles_list); userStyleListLayout.removeAllViews(); for (int i = 0; i < userStyleNames.size(); i++) { View styleItemView = inflater.inflate(R.layout.user_styles_list_item, parent, false); ImageView btnDelete = (ImageView) styleItemView.findViewById(R.id.user_styles_list_btn_delete); btnDelete.setImageDrawable(FontIconDrawable.inflate(context, R.xml.ic_list_trash)); btnDelete.setOnClickListener(onDeleteUserStyle); String name = userStyleNames.get(i); btnDelete.setTag(name); TextView nameView = (TextView) styleItemView.findViewById(R.id.user_styles_list_name); nameView.setText(name); userStyleListLayout.addView(styleItemView); } return view; }
From source file:galilei.kelimekavanozu.activity.ThemeChooserActivity.java
private void setUpPopular() { final ImageView popular = (ImageView) findViewById(R.id.popular); popular.setOnClickListener(new View.OnClickListener() { @Override/*from www. j a va 2s . co m*/ public void onClick(View v) { Crashlytics.log("ThemeChooser: clicked Popular button"); Answers.getInstance().logCustom(new CustomEvent("clicked popular")); Intent intent = new Intent(ThemeChooserActivity.this, PoemPopularActivity.class); startActivity(intent); } }); }
From source file:com.freshdigitable.udonroad.StatusDetailFragment.java
@Override public void onStart() { super.onStart(); final long statusId = getStatusId(); statusRequestWorker.open();//w w w .j ava 2 s .com final TypedCache<Status> statusCache = statusRequestWorker.getCache(); final Status status = statusCache.find(statusId); if (status == null) { Toast.makeText(getContext(), "status is not found", Toast.LENGTH_SHORT).show(); return; } final StatusDetailView statusView = binding.statusView; StatusViewImageHelper.load(status, statusView); final User user = StatusViewImageHelper.getBindingUser(status); final ImageView icon = statusView.getIcon(); final OnUserIconClickedListener userIconClickedListener = createUserIconClickedListener(); icon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { userIconClickedListener.onUserIconClicked(view, user); } }); statusView.getUserName().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { userIconClickedListener.onUserIconClicked(icon, user); } }); statusView.getMediaContainer().setOnMediaClickListener(new OnMediaClickListener() { @Override public void onMediaClicked(View view, int index) { MediaViewActivity.start(view.getContext(), status, index); } }); setTintList(binding.sdFav.getDrawable(), R.color.selector_fav_icon); binding.sdFav.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (status.isFavorited()) { statusRequestWorker.destroyFavorite(statusId); } else { statusRequestWorker.createFavorite(statusId); } } }); setTintList(binding.sdRetweet.getDrawable(), R.color.selector_rt_icon); binding.sdRetweet.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (status.isRetweeted()) { statusRequestWorker.destroyRetweet(statusId); } else { statusRequestWorker.retweetStatus(statusId); } } }); DrawableCompat.setTint(binding.sdReply.getDrawable(), ContextCompat.getColor(getContext(), R.color.twitter_action_normal)); binding.sdReply.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { setupInput(TweetInputFragment.TYPE_REPLY); } }); setTintList(binding.sdQuote.getDrawable(), R.color.twitter_action_normal); binding.sdQuote.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { setupInput(TweetInputFragment.TYPE_QUOTE); } }); subscription = statusCache.observeById(statusId).subscribe(new Action1<Status>() { @Override public void call(Status status) { binding.statusView.bindStatus(status); binding.sdFav.setActivated(status.isFavorited()); binding.sdRetweet.setActivated(status.isRetweeted()); } }); final Status bindingStatus = StatusViewImageHelper.getBindingStatus(status); if (bindingStatus.getURLEntities().length < 1) { return; } if (twitterCard != null) { setupTwitterCard(twitterCard); } else { TwitterCardFetcher.observeFetch(bindingStatus.getURLEntities()[0].getExpandedURL()) .observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<TwitterCard>() { @Override public void call(final TwitterCard twitterCard) { setupTwitterCard(twitterCard); } }, new Action1<Throwable>() { @Override public void call(Throwable throwable) { Log.e(TAG, "card fetch: ", throwable); } }); } }
From source file:net.simno.klingar.ui.PlayerController.java
@Override public void onPrepareOptionsMenu(@NonNull Menu menu) { MenuItem item = menu.findItem(R.id.action_queue_track); ImageView actionView = (ImageView) MenuItemCompat.getActionView(item); actionView.setImageState(isQueueVisible ? TRACK : QUEUE, true); actionView.setContentDescription(isQueueVisible ? descTrack : descQueue); actionView.setOnClickListener(view -> { actionView.setImageState(isQueueVisible ? QUEUE : TRACK, true); actionView.setContentDescription(isQueueVisible ? descQueue : descTrack); toggleQueue();//from w ww. j a v a 2s . c o m }); }
From source file:tf.nox.wifisetup.WifiSetup.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.logon);/*from w w w . j a va 2s . co m*/ flipper = (ViewFlipper) findViewById(R.id.viewflipper); username = (EditText) findViewById(R.id.username); password = (EditText) findViewById(R.id.password); check5g = (CheckBox) findViewById(R.id.check5g); check5g.setChecked(true); /* TextView label5g = (TextView) findViewById(R.id.label5g); if (android.os.Build.VERSION.SDK_INT >= 21) { check5g.setChecked(get5G()); label5g.setText("(autodetected value)"); } else { check5g.setChecked(true); label5g.setText("(Android 5.0 is needed to autodetect this)"); } */ ImageView img = (ImageView) findViewById(R.id.logo); img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { logoclicks++; if (logoclicks == 4) { toastText("You're cute!"); } if (logoclicks == 6) { toastText("Stop that!"); } if (logoclicks == 7) { View logindata = findViewById(R.id.logindata); logindata.setVisibility(View.VISIBLE); } } }); btn = (Button) findViewById(R.id.button1); if (btn == null) throw new RuntimeException("button1 not found. Odd"); btn.setOnClickListener(new Button.OnClickListener() { public void onClick(View _v) { if (busy) { return; } busy = true; _v.setClickable(false); // Most of this stuff runs in the background Thread t = new Thread() { @Override public void run() { try { if (android.os.Build.VERSION.SDK_INT >= 18) { saveWifiConfig(); resultStatus(true, "You should now have a wifi connection entry with correct security settings and certificate verification.\n\nMake sure to actually use it!"); // Clear the password field in the UI thread /* mHandler.post(new Runnable() { @Override public void run() { password.setText(""); }; }); */ } else { throw new RuntimeException("What version is this?! API Mismatch"); } } catch (RuntimeException e) { resultStatus(false, "Something went wrong: " + e.getMessage()); e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } busy = false; mHandler.post(new Runnable() { @Override public void run() { btn.setClickable(true); }; }); } }; t.start(); } }); }
From source file:la.zmkm.agent.activity.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;/*from w w w. ja v a2s .c o m*/ inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(R.id.list); sidebar = (Sidebar) getView().findViewById(R.id.sidebar); sidebar.setListView(listView); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); contactList = new ArrayList<User>(); // ?contactlist getContactList(); //? query = (EditText) getView().findViewById(R.id.query); query.setHint(R.string.search); clearSearch = (ImageButton) getView().findViewById(R.id.search_clear); query.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); if (s.length() > 0) { clearSearch.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.INVISIBLE); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query.getText().clear(); hideSoftKeyboard(); } }); // adapter adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList); 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 = DemoApplication.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())); } } }); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); 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.phicdy.mycuration.ui.TopActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_top); curationFragment = new CurationListFragment(); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.addOnPageChangeListener(new PageChangeListener()); track = (ViewGroup) findViewById(R.id.track); trackScroller = (HorizontalScrollView) findViewById(R.id.track_scroller); indicator = (View) findViewById(R.id.indicator); WindowManager wm = getWindowManager(); Display disp = wm.getDefaultDisplay(); Point size = new Point(); disp.getSize(size);//from w w w .ja va 2 s . c o m int displayWidth = size.x; LayoutInflater inflater = LayoutInflater.from(this); for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { final int position = i; ImageView ivTab = (ImageView) inflater.inflate(R.layout.tab_item, track, false); ivTab.setImageResource(mSectionsPagerAdapter.getImageResource(position)); ivTab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mViewPager.setCurrentItem(position); } }); final LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) ivTab.getLayoutParams(); layoutParams.width = displayWidth / mSectionsPagerAdapter.getCount(); ivTab.setLayoutParams(layoutParams); track.addView(ivTab); } final float density = getResources().getDisplayMetrics().density; indicatorOffset = (int) (INDICATOR_OFFSET_DP * density); setTitle(getString(R.string.home)); dbAdapter = DatabaseAdapter.getInstance(getApplicationContext()); setAlarmManager(); }
From source file:com.jbirdvegas.mgerrit.cards.PatchSetPropertiesCard.java
private void setClicksToActionViews(Cursor cursor, ImageView share, ImageView browser) { String webAddress = getWebAddress(cursor.getString(changenum_index)); share.setTag(R.id.webAddress, webAddress); share.setTag(R.id.changeID, cursor.getString(changeid_index)); browser.setTag(R.id.webAddress, webAddress); share.setOnClickListener(new View.OnClickListener() { @Override// ww w . j a va 2s .co m public void onClick(View view) { String changeId = (String) view.getTag(R.id.changeID); String webAddress = (String) view.getTag(R.id.webAddress); Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Intent.EXTRA_SUBJECT, String.format(view.getContext().getString(R.string.commit_shared_from_mgerrit), changeId)); intent.putExtra(Intent.EXTRA_TEXT, webAddress + " #mGerrit"); view.getContext().startActivity(intent); } }); browser.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String webAddress = (String) view.getTag(R.id.webAddress); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(webAddress)); view.getContext().startActivity(browserIntent); } }); }