List of usage examples for android.widget ImageView setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.surinov.alexander.wallet2wallet.views.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { ImageView tabView = crateDefaultImageView(getContext()); if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0;//from w w w. ja v a 2s. c o m lp.weight = 1; } tabView.setImageResource(((FragmentAdapter) adapter).getDrawableResource(i)); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:com.yahala.ui.Views.EmojiViewExtra.java
private void init() { setOrientation(LinearLayout.VERTICAL); loadRecents();/*from w w w. j ava2 s . com*/ setBackgroundDrawable(new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { Color.parseColor("#FF373737"), Color.parseColor("#FF575757"), Color.parseColor("#FF666666") })); emojiPagerAdapter = new EmojiPagerAdapter(getContext(), EmojiManager.getInstance().categories); pager = new ViewPager(getContext()); pager.setOffscreenPageLimit(5); pager.setAdapter(emojiPagerAdapter); FileLog.e("EmojiManager.emojiGroups", "" + EmojiManager.getInstance().categories.size()); PagerSlidingTabStripEmoji tabs = new PagerSlidingTabStripEmoji(getContext()); tabs.setViewPager(pager); tabs.setShouldExpand(false); tabs.setMinimumWidth(OSUtilities.dp(50)); tabs.setTabPaddingLeftRight(OSUtilities.dp(10)); tabs.setIndicatorHeight(3); //tabs.setTabBackground(Color.parseColor("#FF3f9fe0")); tabs.setTabBackground(R.drawable.bar_selector_main); tabs.setIndicatorColor(Color.parseColor("#FFffffff")); tabs.setDividerColor(Color.parseColor("#ff222222")); tabs.setUnderlineHeight(2); tabs.setUnderlineColor(Color.parseColor("#ff373737")); //tabs.setTabBackground(0); LinearLayout localLinearLayout = new LinearLayout(getContext()); localLinearLayout.setOrientation(LinearLayout.HORIZONTAL); localLinearLayout.addView(tabs, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f)); ImageView localImageView = new ImageView(getContext()); localImageView.setImageResource(R.drawable.ic_emoji_backspace); localImageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); localImageView.setBackgroundResource(R.drawable.bg_emoji_bs); localImageView.setOnClickListener(new OnClickListener() { public void onClick(View view) { if (EmojiViewExtra.this.listener != null) { EmojiViewExtra.this.listener.onBackspace(); } } }); localLinearLayout.addView(localImageView, new LayoutParams(OSUtilities.dpf(61.0f), LayoutParams.MATCH_PARENT)); /* recentsWrap = new FrameLayout(getContext()); recentsWrap.addView(views.get(0)); TextView localTextView = new TextView(getContext()); localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent)); localTextView.setTextSize(18.0f); localTextView.setTextColor(-7829368); localTextView.setGravity(17); recentsWrap.addView(localTextView); views.get(0).setEmptyView(localTextView);*/ addView(localLinearLayout, new LayoutParams(-1, OSUtilities.dpf(48.0f))); addView(pager); if (!EmojiManager.getInstance().categoriesDict.containsKey("recents") || EmojiManager.getInstance().categoriesDict.get("recents").emojis.size() == 0) { pager.setCurrentItem(1); } }
From source file:cn.ucai.yizhesale.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 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<EMUser>(); // ?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)) { // ? EMUser user = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList() .get(Constant.NEW_FRIENDS_USERNAME); user.setUnreadMsgCount(0); startActivity(new Intent(getActivity(), NewFriendsMsgActivity.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); progressBar = (View) getView().findViewById(R.id.progress_bar); contactSyncListener = new HXContactSyncListener(); HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener); blackListSyncListener = new HXBlackListSyncListener(); HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener); contactInfoSyncListener = new HXContactInfoSyncListener(); ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager() .addSyncContactInfoListener(contactInfoSyncListener); if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) { progressBar.setVisibility(View.VISIBLE); } else { progressBar.setVisibility(View.GONE); } }
From source file:com.amagi82.kerbalspaceapp.MissionPlanner.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_mission_planner); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(true); getActionBar().setTitle(R.string.title_activity_mission_planner); if (savedInstanceState == null) { // Load saved missionData if available. try {/*from w ww . j av a 2 s. c o m*/ FileInputStream inStream = new FileInputStream( Environment.getExternalStorageDirectory() + File.separator + "MissionData"); ObjectInputStream objectInStream = new ObjectInputStream(inStream); int count = objectInStream.readInt(); for (int i = 0; i < count; i++) missionData.add((MissionData) objectInStream.readObject()); objectInStream.close(); } catch (OptionalDataException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // if the list is empty, add the default planet if (missionData.size() == 0) { missionData = setFirstMissionData(); } } else { missionData = savedInstanceState.getParcelableArrayList("key"); } mBackgroundContainer = (BackgroundContainer) findViewById(R.id.listViewBackground); mListView = (ListView) findViewById(R.id.list); tvTotalDeltaV = (TextView) findViewById(R.id.tvTotalDeltaV); mAdapter = new StableArrayAdapter(this, missionData, mTouchListener); // add the newDestination button as a footer below the listview ImageView newDestination = new ImageView(this); newDestination.setImageResource(R.drawable.ic_plus); mListView.addFooterView(newDestination); newDestination.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int possibleIconState = 0; // Lets MissionDestination know which icons it's allowed to use if (missionData.size() < 1) { possibleIconState = 1; } Intent intent = new Intent(MissionPlanner.this, MissionDestination.class); intent.putExtra("possibleIconState", possibleIconState); intent.putExtra("isNewItem", true); // Places the result as a new item in the listview startActivityForResult(intent, 0); } }); mListView.setAdapter(mAdapter); }
From source file:com.yi4all.rupics.IssueListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.issue_list_fragment, container, false); postListView = (MultiColumnPullToRefreshListView) v.findViewById(R.id.issueListView); // postListView.setChoiceMode(ListView.CHOICE_MODE_NONE); default_image = BitmapFactory.decodeResource(getResources(), R.drawable.download_32); no_image = BitmapFactory.decodeResource(getResources(), R.drawable.no_image); TextView tv = (TextView) v.findViewById(R.id.issue_title_txt); tv.setText(category.getName());/* www . ja v a 2 s. co m*/ ImageView iv = (ImageView) v.findViewById(R.id.issue_back_btn); iv.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { getActivity().finish(); } }); display = getActivity().getWindowManager().getDefaultDisplay(); final DisplayMetrics displayMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); final int height = displayMetrics.heightPixels; final int width = displayMetrics.widthPixels; SCREEN_WIDTH = width; SCREEN_HEIGHT = height; initPostList(); return v; }
From source file:com.crearo.gpslogger.ui.fragments.display.GpsSimpleViewFragment.java
private void setImageTooltips() { ImageView imgSatellites = (ImageView) rootView.findViewById(R.id.simpleview_imgSatelliteCount); imgSatellites.setOnClickListener(this); ImageView imgAccuracy = (ImageView) rootView.findViewById(R.id.simpleview_imgAccuracy); imgAccuracy.setOnClickListener(this); ImageView imgElevation = (ImageView) rootView.findViewById(R.id.simpleview_imgAltitude); imgElevation.setOnClickListener(this); ImageView imgBearing = (ImageView) rootView.findViewById(R.id.simpleview_imgDirection); imgBearing.setOnClickListener(this); ImageView imgDuration = (ImageView) rootView.findViewById(R.id.simpleview_imgDuration); imgDuration.setOnClickListener(this); ImageView imgSpeed = (ImageView) rootView.findViewById(R.id.simpleview_imgSpeed); imgSpeed.setOnClickListener(this); ImageView imgDistance = (ImageView) rootView.findViewById(R.id.simpleview_distance); imgDistance.setOnClickListener(this); ImageView imgPoints = (ImageView) rootView.findViewById(R.id.simpleview_points); imgPoints.setOnClickListener(this); ImageView imgLink = (ImageView) rootView.findViewById(R.id.simpleview_imgLink); imgLink.setOnClickListener(this); }
From source file:com.wlzndjk.poker.widget.MyHScrollView.java
public void setViewPager(ViewPager pager, ImageView leftBtn, ImageView rightBtn, List<Integer> datas) { this.viewPager = pager; this.tabDatas = datas; this.mLeft = leftBtn; this.mRight = rightBtn; if (pager.getAdapter() == null) { throw new IllegalStateException("ViewPager does not have adapter instance."); }/*w w w. ja va 2 s . co m*/ pager.setOnPageChangeListener(pageListener); rightBtn.setOnClickListener(rightListener); leftBtn.setOnClickListener(leftListener); notifyDataSetChanged(); }
From source file:com.rdio.android.api.example.ExampleActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//ww w .ja v a 2 s . c o m trackQueue = new LinkedList<Track>(); // Initialize our Rdio object. If we have cached access credentials, then use them - otherwise // Initialize w/ null values and the user will be prompted (if the Rdio app is installed), or // we'll fallback to 30s samples. if (rdio == null) { SharedPreferences settings = getPreferences(MODE_PRIVATE); accessToken = settings.getString(PREF_ACCESSTOKEN, null); accessTokenSecret = settings.getString(PREF_ACCESSTOKENSECRET, null); rdio = new Rdio(appKey, appSecret, accessToken, accessTokenSecret, this, this); if (accessToken == null || accessTokenSecret == null) { // If either one is null, reset both of them accessToken = accessTokenSecret = null; Intent myIntent = new Intent(ExampleActivity.this, OAuth1WebViewActivity.class); myIntent.putExtra(OAuth1WebViewActivity.EXTRA_CONSUMER_KEY, appKey); myIntent.putExtra(OAuth1WebViewActivity.EXTRA_CONSUMER_SECRET, appSecret); ExampleActivity.this.startActivityForResult(myIntent, 1); } else { Log.d(TAG, "Found cached credentials:"); Log.d(TAG, "Access token: " + accessToken); Log.d(TAG, "Access token secret: " + accessTokenSecret); rdio.prepareForPlayback(); } } ImageView i = (ImageView) findViewById(R.id.next); i.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { next(true); } }); playPause = (ImageView) findViewById(R.id.playPause); playPause.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { playPause(); } }); albumArt = (ImageView) findViewById(R.id.albumArt); }
From source file:com.eason.marker.emchat.chatuidemo.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 . java 2s . 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<EMUser>(); // ?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)) { // ? EMUser EMUser = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList() .get(Constant.NEW_FRIENDS_USERNAME); EMUser.setUnreadMsgCount(0); startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class)); } else if (Constant.GROUP_USERNAME.equals(username)) { // ?? // startActivity(new Intent(getActivity(), GroupsActivity.class)); } else if (Constant.CHAT_ROOM.equals(username)) { //?? startActivity(new Intent(getActivity(), PublicChatRoomsActivity.class)); } else if (Constant.CHAT_ROBOT.equals(username)) { //Robot? startActivity(new Intent(getActivity(), RobotsActivity.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); progressBar = (View) getView().findViewById(R.id.progress_bar); contactSyncListener = new HXContactSyncListener(); HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener); blackListSyncListener = new HXBlackListSyncListener(); HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener); contactInfoSyncListener = new HXContactInfoSyncListener(); ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager() .addSyncContactInfoListener(contactInfoSyncListener); if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) { progressBar.setVisibility(View.VISIBLE); } else { progressBar.setVisibility(View.GONE); } }
From source file:com.google.dotorg.crisisresponse.translationcards.RecordingActivity.java
private void moveToLabelStep() { setContentView(R.layout.recording_label); recycleBitmap();/* w w w . ja v a 2 s .c o m*/ currentBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.recording_label_image); currentBitmapView = (ImageView) findViewById(R.id.recording_label_image); currentBitmapView.setImageBitmap(currentBitmap); final EditText labelField = (EditText) findViewById(R.id.recording_label_field); if (label != null) { labelField.setText(label); labelField.setTextColor(Color.BLACK); labelField.setSelection(label.length()); setLabelNextButtonEnabled(true); } if (inEditMode) { ImageView deleteButton = (ImageView) findViewById(R.id.recording_label_delete_image); deleteButton.setVisibility(View.VISIBLE); deleteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DbManager dbm = new DbManager(RecordingActivity.this); dbm.deleteTranslation(translationId); if (!isAsset) { File oldFile = new File(filename); oldFile.delete(); if (!savedIsAsset && (savedFilename != null) && !savedFilename.equals(filename)) { oldFile = new File(savedFilename); oldFile.delete(); } } setResult(RESULT_OK); finish(); } }); findViewById(R.id.recording_label_step_marker).setVisibility(View.GONE); } labelField.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus && labelField.getText().toString().equals(getString(R.string.recording_label_hint_text))) { labelField.setText(""); labelField.setTextColor(Color.BLACK); } else if (!hasFocus && labelField.getText().toString().equals("")) { labelField.setText(getString(R.string.recording_label_hint_text)); labelField.setTextColor(getResources().getColor(R.color.borderColor)); } if (hasFocus) { InputMethodManager inputMethodManager = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); inputMethodManager.toggleSoftInputFromWindow(labelField.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0); } } }); labelField.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Do nothing here. } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (s.length() != 0 && !s.equals(getString(R.string.recording_label_hint_text))) { setLabelNextButtonEnabled(true); } else { setLabelNextButtonEnabled(false); } } @Override public void afterTextChanged(Editable s) { // Do nothing here. } }); View nextButton = (View) findViewById(R.id.recording_label_next); nextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { label = labelField.getText().toString(); if (label.length() == 0 || label.equals(getString(R.string.recording_label_hint_text))) { return; } moveToAudioStep(); } }); stepHistory.push(Step.LABEL); }