List of usage examples for android.widget TextView setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.tune.news.fragment.EntriesListFragment.java
@Override public View inflateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_entry_list, container, true); if (mEntriesCursorAdapter != null) { setListAdapter(mEntriesCursorAdapter); }//w w w .ja va 2s . co m mListView = (ListView) rootView.findViewById(android.R.id.list); mListView.setFastScrollEnabled(true); // mListView.setOnTouchListener(new SwipeGestureListener(mListView.getContext())); if (PrefUtils.getBoolean(PrefUtils.DISPLAY_TIP, true)) { final TextView header = new TextView(mListView.getContext()); header.setMinimumHeight(UiUtils.dpToPixel(70)); int footerPadding = UiUtils.dpToPixel(10); header.setPadding(footerPadding, footerPadding, footerPadding, footerPadding); header.setText(R.string.tip_sentence); header.setGravity(Gravity.CENTER_VERTICAL); header.setCompoundDrawablePadding(UiUtils.dpToPixel(5)); header.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_action_about, 0, R.drawable.ic_action_cancel, 0); header.setClickable(true); header.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mListView.removeHeaderView(header); PrefUtils.putBoolean(PrefUtils.DISPLAY_TIP, false); } }); mListView.addHeaderView(header); } UiUtils.addEmptyFooterView(mListView, 90); mHideReadButton = (FloatingActionButton) rootView.findViewById(R.id.hide_read_button); mHideReadButton.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { UiUtils.displayHideReadButtonAction(mListView.getContext()); return true; } }); UiUtils.updateHideReadButton(mHideReadButton); mRefreshListBtn = (Button) rootView.findViewById(R.id.refreshListBtn); mRefreshListBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mNewEntriesNumber = 0; mListDisplayDate = new Date().getTime(); refreshUI(); if (mUri != null) { restartLoaders(); } } }); mSearchView = (SearchView) rootView.findViewById(R.id.searchView); if (savedInstanceState != null) { refreshUI(); // To hide/show the search bar } mSearchView.post(new Runnable() { // Do this AFTER the text has been restored from saveInstanceState @Override public void run() { mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String s) { InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mSearchView.getWindowToken(), 0); return false; } @Override public boolean onQueryTextChange(String s) { setData(EntryColumns.SEARCH_URI(s), true); return false; } }); } }); disableSwipe(); return rootView; }
From source file:com.cssweb.android.base.DialogActivity.java
protected void initStockBar() { hiddenOrDisplayStockBar(View.VISIBLE); TextView stkBar1 = (TextView) findViewById(R.id.njzq_userstockbtn1); TextView stkBar2 = (TextView) findViewById(R.id.njzq_userstockbtn2); TextView stkBar3 = (TextView) findViewById(R.id.njzq_userstockbtn3); TextView stkBar4 = (TextView) findViewById(R.id.njzq_userstockbtn4); TextView stkBar5 = (TextView) findViewById(R.id.njzq_userstockbtn5); TextView stkBar6 = (TextView) findViewById(R.id.njzq_userstockbtn6); stkBar1.setTextColor(getResources().getColor(R.color.zr_white)); stkBar1.setOnClickListener(toolbarClick); stkBar1.setVisibility(View.VISIBLE); stkBar1.setTag(11);/* w w w . j av a 2 s. co m*/ stkBar2.setTextColor(getResources().getColor(R.color.zr_white)); stkBar2.setOnClickListener(toolbarClick); stkBar2.setVisibility(View.VISIBLE); stkBar2.setTag(12); stkBar3.setTextColor(getResources().getColor(R.color.zr_white)); stkBar3.setOnClickListener(toolbarClick); stkBar3.setVisibility(View.VISIBLE); stkBar3.setTag(13); stkBar4.setTextColor(getResources().getColor(R.color.zr_white)); stkBar4.setOnClickListener(toolbarClick); stkBar4.setVisibility(View.VISIBLE); stkBar4.setTag(14); stkBar5.setTextColor(getResources().getColor(R.color.zr_white)); stkBar5.setOnClickListener(toolbarClick); stkBar5.setVisibility(View.VISIBLE); stkBar5.setTag(15); stkBar6.setTextColor(getResources().getColor(R.color.zr_white)); stkBar6.setOnClickListener(toolbarClick); stkBar6.setVisibility(View.VISIBLE); stkBar6.setTag(16); }
From source file:com.cleanwiz.applock.ui.adapter.MainPagerAdapter.java
@SuppressLint("InflateParams") private View buildLockView() { View view = mInflater.inflate(R.layout.pager_applock, null); ListView listView = (ListView) view.findViewById(R.id.lv_apps); final LockAdapter adapter = new LockAdapter(mContext); View header = mInflater.inflate(R.layout.pager_applock_header, null); final TextView tvSortAlpha = (TextView) header.findViewById(R.id.sort_alpha); final TextView tvSortDefault = (TextView) header.findViewById(R.id.sort_default); final int colorRed = mContext.getResources().getColor(R.color.text_red); final int colorBlack = mContext.getResources().getColor(R.color.md_black_1); View.OnClickListener onSort = new View.OnClickListener() { @Override//from w w w .j a va2s.c o m public void onClick(View v) { switch (v.getId()) { case R.id.sort_alpha: tvSortAlpha.setTextColor(colorRed); tvSortDefault.setTextColor(colorBlack); adapter.onSort(LockAdapter.SORT_ALPHA); break; case R.id.sort_default: tvSortAlpha.setTextColor(colorBlack); tvSortDefault.setTextColor(colorRed); adapter.onSort(LockAdapter.SORT_DEFAULT); break; } } }; tvSortAlpha.setOnClickListener(onSort); tvSortDefault.setOnClickListener(onSort); listView.addHeaderView(header); listView.setAdapter(adapter); return view; }
From source file:com.viktorrudometkin.burramys.fragment.EntriesListFragment.java
@Override public View inflateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_entry_list, container, true); if (mEntriesCursorAdapter != null) { setListAdapter(mEntriesCursorAdapter); }//from w ww . j a v a2 s . co m mListView = (ListView) rootView.findViewById(android.R.id.list); mListView.setOnTouchListener(new SwipeGestureListener(mListView.getContext())); if (PrefUtils.getBoolean(PrefUtils.DISPLAY_TIP, true)) { final TextView header = new TextView(mListView.getContext()); header.setMinimumHeight(UiUtils.dpToPixel(70)); int footerPadding = UiUtils.dpToPixel(10); header.setPadding(footerPadding, footerPadding, footerPadding, footerPadding); header.setText(R.string.tip_sentence); header.setGravity(Gravity.CENTER_VERTICAL); header.setCompoundDrawablePadding(UiUtils.dpToPixel(5)); header.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_action_about, 0, R.drawable.ic_action_cancel, 0); header.setClickable(true); header.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mListView.removeHeaderView(header); PrefUtils.putBoolean(PrefUtils.DISPLAY_TIP, false); } }); mListView.addHeaderView(header); } UiUtils.addEmptyFooterView(mListView, 90); mRefreshListBtn = (Button) rootView.findViewById(R.id.refreshListBtn); mRefreshListBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mNewEntriesNumber = 0; mListDisplayDate = new Date().getTime(); refreshUI(); if (mCurrentUri != null) { restartLoaders(); } } }); disableSwipe(); return rootView; }
From source file:com.garlicg.screenrecord4cm.SettingsActivity.java
/** * TriggerTitle/*from ww w . ja v a 2s . c om*/ */ private void createTriggerTitle(Bundle savedInstanceState) { final TextView valueView = ViewFinder.byId(this, R.id.triggerTitleValue); String value = mPrefs.getTriggerTitle(); valueView.setText(value); // handle value from dialog callback final ValidateTextDialogBuilder.Callback callback = new ValidateTextDialogBuilder.Callback() { @Override public boolean onValidate(CharSequence value) { return !TextUtils.isEmpty(value); } @Override public void onOk(CharSequence value) { valueView.setText(value); mPrefs.saveTriggerTitle(value.toString()); } }; // show dialog on click valueView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String value = mPrefs.getTriggerTitle(); AlertDialog ad = ValidateTextDialogBuilder.build(v.getContext(), value, null, 50, callback); ad.show(); } }); }
From source file:com.garlicg.screenrecord4cm.SettingsActivity.java
/** * TriggerMessage//w ww .j av a 2 s .co m */ private void createTriggerMessage(Bundle savedInstanceState) { final TextView valueView = ViewFinder.byId(this, R.id.triggerMessageValue); String value = mPrefs.getTriggerMessage(); valueView.setText(value); // handle value from dialog callback final ValidateTextDialogBuilder.Callback callback = new ValidateTextDialogBuilder.Callback() { @Override public boolean onValidate(CharSequence value) { return !TextUtils.isEmpty(value); } @Override public void onOk(CharSequence value) { valueView.setText(value); mPrefs.saveTriggerMessage(value.toString()); } }; // show dialog on click valueView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String value = mPrefs.getTriggerMessage(); AlertDialog ad = ValidateTextDialogBuilder.build(v.getContext(), value, null, 100, callback); ad.show(); } }); }
From source file:com.android.launcher3.Hotseat.java
void resetLayout() { mContent.removeAllViewsInLayout();//www .ja v a 2 s . com if (!FeatureFlags.NO_ALL_APPS_ICON) { // Add the Apps button Context context = getContext(); int allAppsButtonRank = mLauncher.getDeviceProfile().inv.getAllAppsButtonRank(); LayoutInflater inflater = LayoutInflater.from(context); TextView allAppsButton = (TextView) inflater.inflate(R.layout.all_apps_button, mContent, false); Drawable d = context.getResources().getDrawable(R.drawable.all_apps_button_icon); mLauncher.resizeIconDrawable(d); int scaleDownPx = getResources().getDimensionPixelSize(R.dimen.all_apps_button_scale_down); Rect bounds = d.getBounds(); d.setBounds(bounds.left, bounds.top + scaleDownPx / 2, bounds.right - scaleDownPx, bounds.bottom - scaleDownPx / 2); allAppsButton.setCompoundDrawables(null, d, null, null); allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label)); allAppsButton.setOnKeyListener(new HotseatIconKeyEventListener()); if (mLauncher != null) { mLauncher.setAllAppsButton(allAppsButton); allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener()); allAppsButton.setOnClickListener(mLauncher); allAppsButton.setOnLongClickListener(mLauncher); allAppsButton.setOnFocusChangeListener(mLauncher.mFocusHandler); } // Note: We do this to ensure that the hotseat is always laid out in the orientation of // the hotseat in order regardless of which orientation they were added int x = getCellXFromOrder(allAppsButtonRank); int y = getCellYFromOrder(allAppsButtonRank); CellLayout.LayoutParams lp = new CellLayout.LayoutParams(x, y, 1, 1); lp.canReorder = false; mContent.addViewToCellLayout(allAppsButton, -1, allAppsButton.getId(), lp, true); } }
From source file:com.ass.ui.View.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;//from www. j a v a 2s . co m TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); tabTitleView.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:io.plaidapp.ui.DesignerNewsStory.java
private void bindDescription() { final TextView storyComment = (TextView) header.findViewById(R.id.story_comment); if (!TextUtils.isEmpty(story.comment)) { HtmlUtils.parseMarkdownAndSetText(storyComment, story.comment, markdown, new Bypass.LoadImageCallback() { @Override//from ww w . j a va2s. c o m public void loadImage(String src, ImageLoadingSpan loadingSpan) { Glide.with(DesignerNewsStory.this).load(src).asBitmap() .diskCacheStrategy(DiskCacheStrategy.ALL) .into(new ImageSpanTarget(storyComment, loadingSpan)); } }); } else { storyComment.setVisibility(View.GONE); } upvoteStory = (TextView) header.findViewById(R.id.story_vote_action); upvoteStory.setText(getResources().getQuantityString(R.plurals.upvotes, story.vote_count, NumberFormat.getInstance().format(story.vote_count))); upvoteStory.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { upvoteStory(); } }); final TextView share = (TextView) header.findViewById(R.id.story_share_action); share.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((AnimatedVectorDrawable) share.getCompoundDrawables()[1]).start(); startActivity(ShareCompat.IntentBuilder.from(DesignerNewsStory.this).setText(story.url) .setType("text/plain").setSubject(story.title).getIntent()); } }); TextView storyPosterTime = (TextView) header.findViewById(R.id.story_poster_time); SpannableString poster = new SpannableString(story.user_display_name.toLowerCase()); poster.setSpan(new TextAppearanceSpan(this, R.style.TextAppearance_CommentAuthor), 0, poster.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); CharSequence job = !TextUtils.isEmpty(story.user_job) ? "\n" + story.user_job.toLowerCase() : ""; CharSequence timeAgo = DateUtils.getRelativeTimeSpanString(story.created_at.getTime(), System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS).toString().toLowerCase(); storyPosterTime.setText(TextUtils.concat(poster, job, "\n", timeAgo)); ImageView avatar = (ImageView) header.findViewById(R.id.story_poster_avatar); if (!TextUtils.isEmpty(story.user_portrait_url)) { Glide.with(this).load(story.user_portrait_url).placeholder(R.drawable.avatar_placeholder) .transform(circleTransform).into(avatar); } else { avatar.setVisibility(View.GONE); } }