List of usage examples for android.widget TextView setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.bangqu.eshow.view.sliding.ESSlidingSmoothFixTabView.java
/** * ??tab./*from w w w . j av a2 s .c o m*/ * * @param tabText the tab text * @param fragment the fragment */ public void addItemView(String tabText, Fragment fragment) { tabItemTextList.add(tabText); pagerItemList.add(fragment); tabItemList.clear(); mTabLayout.removeAllViews(); for (int i = 0; i < tabItemTextList.size(); i++) { final int index = i; String text = tabItemTextList.get(i); TextView tv = new TextView(this.context); tv.setTextColor(tabColor); tv.setTextSize(tabTextSize); tv.setText(text); tv.setGravity(Gravity.CENTER); tv.setLayoutParams(new LayoutParams(0, LayoutParams.FILL_PARENT, 1)); tv.setPadding(12, 5, 12, 5); tv.setFocusable(false); tabItemList.add(tv); mTabLayout.addView(tv); tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mViewPager.setCurrentItem(index); } }); } //? ESLogUtil.d(ESSlidingSmoothFixTabView.class, "addItemView finish"); mFragmentPagerAdapter.notifyDataSetChanged(); mViewPager.setCurrentItem(0); computeTabImg(0); }
From source file:com.chalilayang.test.customview.springindicator.SpringIndicator.java
private void addTabItems() { LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1.0f); tabs = new ArrayList<>(); for (int i = 0; i < viewPager.getAdapter().getCount(); i++) { TextView textView = new TextView(getContext()); if (viewPager.getAdapter().getPageTitle(i) != null) { textView.setText(viewPager.getAdapter().getPageTitle(i)); }//from w w w . jav a2 s .co m textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); textView.setTextColor(getResources().getColor(textColorId)); if (textBgResId != 0) { textView.setBackgroundResource(textBgResId); } textView.setLayoutParams(layoutParams); final int position = i; textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (tabClickListener == null || tabClickListener.onTabClick(position)) { viewPager.setCurrentItem(position); } } }); tabs.add(textView); tabContainer.addView(textView); } }
From source file:com.zch.safelottery.view.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { final int color = tabTextColor; TextView tab = new TextView(getContext()); tab.setText(title);/*from ww w . jav a 2 s.c o m*/ tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setTextColor(color); if (position == 0) { tab.setTextColor(indicatorColor); } tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int childCount = tabsContainer.getChildCount(); for (int i = 0; i < childCount; i++) { TextView child = (TextView) tabsContainer.getChildAt(i); child.setTextColor(color); } TextView cur = (TextView) tabsContainer.getChildAt(position); cur.setTextColor(indicatorColor); pager.setCurrentItem(position); } }); tabsContainer.addView(tab); }
From source file:be.matteotaroli.pomodoro.IntroFragment.java
@Nullable @Override//from w w w . ja v a2s . co m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = getActivity().getLayoutInflater().inflate(R.layout.fragment_intro_page, container, false); mPager = ((IntroActivity) getActivity()).getPager(); TextView titleTv = (TextView) view.findViewById(R.id.intro_title_textView); TextView textTv = (TextView) view.findViewById(R.id.intro_text_textView); ImageView pictureIV = (ImageView) view.findViewById(R.id.intro_picture_imageView); TextView skipTv = (TextView) view.findViewById(R.id.intro_skip); TextView nextTv = (TextView) view.findViewById(R.id.intro_next); View.OnClickListener skipIntro = new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), TimerActivity.class); startActivity(intent); getActivity().finish(); } }; View.OnClickListener next = new View.OnClickListener() { @Override public void onClick(View v) { mPager.setCurrentItem(mPage + 1); } }; if (mPage == IntroAdapter.PAGE_COUNT - 1) { /* Last page */ skipTv.setVisibility(View.INVISIBLE); nextTv.setText(R.string.lets_start); nextTv.setOnClickListener(skipIntro); titleTv.setText(R.string.intro_end_title); textTv.setText(R.string.intro_end_text); pictureIV.setImageResource(R.drawable.pomodoro); pictureIV.setContentDescription(getResources().getString(R.string.logo_description)); } else { /* Any other page */ skipTv.setOnClickListener(skipIntro); nextTv.setText(R.string.intro_next); nextTv.setOnClickListener(next); titleTv.setText(pages[mPage][0]); textTv.setText(pages[mPage][1]); /* TODO - v 0.1.0 - add pictures and uncomment those lines pictureIV.setImageResource(pages[mPage][2]); pictureIV.setContentDescription(getResources().getString(pages[mPage][3])); */ } view.setTag(mPage); return view; }
From source file:com.android.contacts.activities.ContactSelectionActivity.java
private void updateAddContactsButton(int count) { final TextView textView = (TextView) mActionBarAdapter.getSelectionContainer() .findViewById(R.id.add_contacts); if (count > 0) { textView.setVisibility(View.VISIBLE); textView.setAllCaps(true);/*from www.jav a2s. c o m*/ textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final long[] contactIds = getMultiSelectListFragment().getSelectedContactIdsArray(); returnSelectedContacts(contactIds); } }); } else { textView.setVisibility(View.GONE); } }
From source file:com.jiandanbaoxian.fragment.DialogFragmentCreater.java
private Dialog showSingleChoiceDialog(final Context mContext) { View convertView = LayoutInflater.from(mContext).inflate(R.layout.dialog_single_choice, null); final Dialog dialog = new Dialog(mContext, R.style.CustomDialog); View.OnClickListener listener = new View.OnClickListener() { @Override/*from ww w . j a v a2 s . c o m*/ public void onClick(View v) { switch (v.getId()) { case R.id.tv_confirm: onDialogClickLisenter.viewClick("tv_confirm"); dismiss(); break; } } }; TextView tv_confirm = (TextView) convertView.findViewById(R.id.tv_confirm); TextView tv_explain = (TextView) convertView.findViewById(R.id.tv_explain); tv_explain.setText(StringConstant.TEXT_SHOW_AFTER_CALL_POLICE_SUCCESS); if (onDialogClickLisenter != null) { onDialogClickLisenter.controlView(tv_confirm, null, null, tv_explain); } tv_confirm.setOnClickListener(listener); dialog.setContentView(convertView); dialog.getWindow().setWindowAnimations(R.style.dialog_right_control_style); return dialog; }
From source file:com.github.vseguip.sweet.contacts.SweetConflictResolveActivity.java
/** * @param fieldTable/*from w w w . j av a2s . co m*/ * @param nameOfField * @param field */ private void addConflictRow(TableLayout fieldTable, final String nameOfField, final String fieldLocal, final String fieldRemote) { if (mCurrentLocal == null || mCurrentSugar == null) return; // String fieldLocal = mCurrentLocal.get(nameOfField); // String fieldRemote = mCurrentSugar.get(nameOfField); TableRow row = new TableRow(this); final Spinner sourceSelect = new Spinner(this); sourceSelect.setBackgroundResource(R.drawable.black_underline); ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, this.getResources().getStringArray(R.array.conflict_sources)); spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sourceSelect.setAdapter(spinnerArrayAdapter); // Open the spinner when pressing any of the text fields OnClickListener spinnerOpener = new OnClickListener() { @Override public void onClick(View v) { sourceSelect.performClick(); } }; row.addView(sourceSelect); fieldTable.addView(row); row = new TableRow(this); TextView fieldName = new TextView(this); int stringId = this.getResources().getIdentifier(nameOfField, "string", this.getPackageName()); fieldName.setText(this.getString(stringId)); fieldName.setTextSize(16); fieldName.setPadding(fieldName.getPaddingLeft(), fieldName.getPaddingTop(), fieldName.getPaddingRight() + 10, fieldName.getPaddingBottom()); fieldName.setOnClickListener(spinnerOpener); row.addView(fieldName); final TextView fieldValueLocal = new TextView(this); fieldValueLocal.setText(fieldLocal); fieldValueLocal.setTextSize(16); row.addView(fieldValueLocal); fieldValueLocal.setOnClickListener(spinnerOpener); fieldTable.addView(row); row = new TableRow(this); row.addView(new TextView(this));// add dummy control final TextView fieldValueRemote = new TextView(this); fieldValueRemote.setText(fieldRemote); fieldValueRemote.setTextSize(16); fieldValueRemote.setOnClickListener(spinnerOpener); row.addView(fieldValueRemote); sourceSelect.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position == 0) { fieldValueLocal.setTextAppearance(SweetConflictResolveActivity.this, R.style.textSelected); fieldValueRemote.setTextAppearance(SweetConflictResolveActivity.this, R.style.textUnselected); resolvedContacts[mPosResolved].set(nameOfField, fieldLocal); } else { fieldValueLocal.setTextAppearance(SweetConflictResolveActivity.this, R.style.textUnselected); fieldValueRemote.setTextAppearance(SweetConflictResolveActivity.this, R.style.textSelected); resolvedContacts[mPosResolved].set(nameOfField, fieldRemote); } } @Override public void onNothingSelected(AdapterView<?> view) { } }); row.setPadding(row.getLeft(), row.getTop() + 5, row.getRight(), row.getBottom() + 10); // Restore appropiate selections according to resolved contact if (resolvedContacts[mPosResolved].get(nameOfField).equals(fieldLocal)) { sourceSelect.setSelection(0); } else { sourceSelect.setSelection(1); } fieldTable.addView(row); }
From source file:com.tony.selene.sliding.AbSlidingSmoothFixTabView.java
/** * ??tab./*from w w w . ja va 2 s .co m*/ * * @param tabTexts * the tab texts * @param fragments * the fragments */ public void addItemViews(List<String> tabTexts, List<Fragment> fragments) { tabItemTextList.addAll(tabTexts); pagerItemList.addAll(fragments); tabItemList.clear(); mTabLayout.removeAllViews(); for (int i = 0; i < tabItemTextList.size(); i++) { final int index = i; String text = tabItemTextList.get(i); TextView tv = new TextView(this.context); tv.setTextColor(tabColor); tv.setTextSize(tabTextSize); tv.setText(text); tv.setGravity(Gravity.CENTER); tv.setLayoutParams(new LayoutParams(0, LayoutParams.FILL_PARENT, 1)); tv.setPadding(12, 5, 12, 5); tv.setFocusable(false); tabItemList.add(tv); mTabLayout.addView(tv); tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mViewPager.setCurrentItem(index); } }); } // ? mFragmentPagerAdapter.notifyDataSetChanged(); mViewPager.setCurrentItem(0); computeTabImg(0); }
From source file:com.tony.selene.sliding.AbSlidingSmoothFixTabView.java
/** * ??tab./* ww w . j a v a 2 s .c om*/ * * @param tabText * the tab text * @param fragment * the fragment */ public void addItemView(String tabText, Fragment fragment) { tabItemTextList.add(tabText); pagerItemList.add(fragment); tabItemList.clear(); mTabLayout.removeAllViews(); for (int i = 0; i < tabItemTextList.size(); i++) { final int index = i; String text = tabItemTextList.get(i); TextView tv = new TextView(this.context); tv.setTextColor(tabColor); tv.setTextSize(tabTextSize); tv.setText(text); tv.setGravity(Gravity.CENTER); tv.setLayoutParams(new LayoutParams(0, LayoutParams.FILL_PARENT, 1)); tv.setPadding(12, 5, 12, 5); tv.setFocusable(false); tabItemList.add(tv); mTabLayout.addView(tv); tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mViewPager.setCurrentItem(index); } }); } // ? AbLogUtil.d(AbSlidingSmoothFixTabView.class, "addItemView finish"); mFragmentPagerAdapter.notifyDataSetChanged(); mViewPager.setCurrentItem(0); computeTabImg(0); }
From source file:com.linute.linute.UtilsAndHelpers.CustomSnackbar.java
/** * Set the action to be displayed in this {}. * * @param text Text to display/*from w w w .jav a 2 s . c om*/ * @param listener callback to be invoked when the action is clicked */ @NonNull public CustomSnackbar setAction(CharSequence text, final View.OnClickListener listener) { final TextView tv = mView.getActionView(); if (TextUtils.isEmpty(text) || listener == null) { tv.setVisibility(View.GONE); tv.setOnClickListener(null); } else { tv.setVisibility(View.VISIBLE); tv.setText(text); tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { listener.onClick(view); // Now dismiss the Snackbar dispatchDismiss(Callback.DISMISS_EVENT_ACTION); } }); } return this; }