List of usage examples for android.widget TextView setFocusable
public void setFocusable(boolean focusable)
From source file:cn.com.zzwfang.view.indicator.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setLayoutParams(getLayoutParams()); tab.setText(title);/*from w ww .j a va2s. c om*/ tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tab); }
From source file:com.hybunion.member.view.PagerSlidingTabStrip.java
private void addTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setWidth(screenWidth / tabCount);// tab.setText(title);//from www . j a va 2s . com tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tab); }
From source file:eu.geopaparazzi.core.maptools.FeaturePageAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { final Feature feature = featuresList.get(position); int bgColor = Compat.getColor(context, eu.geopaparazzi.library.R.color.formbgcolor); int textColor = Compat.getColor(context, eu.geopaparazzi.library.R.color.formcolor); ScrollView scrollView = new ScrollView(context); ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);//from w w w . j ava2 s . c om scrollLayoutParams.setMargins(10, 10, 10, 10); scrollView.setLayoutParams(scrollLayoutParams); scrollView.setBackgroundColor(bgColor); LinearLayout linearLayoutView = new LinearLayout(context); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); int margin = 10; layoutParams.setMargins(margin, margin, margin, margin); linearLayoutView.setLayoutParams(layoutParams); linearLayoutView.setOrientation(LinearLayout.VERTICAL); int padding = 10; linearLayoutView.setPadding(padding, padding, padding, padding); scrollView.addView(linearLayoutView); List<String> attributeNames = feature.getAttributeNames(); List<String> attributeValues = feature.getAttributeValuesStrings(); List<String> attributeTypes = feature.getAttributeTypes(); for (int i = 0; i < attributeNames.size(); i++) { final String name = attributeNames.get(i); String value = attributeValues.get(i); String typeString = attributeTypes.get(i); EDataType type = EDataType.getType4Name(typeString); TextView textView = new TextView(context); textView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); textView.setPadding(padding, padding, padding, padding); textView.setText(name); textView.setTextColor(textColor); // textView.setTextAppearance(context, android.R.style.TextAppearance_Medium); linearLayoutView.addView(textView); final TextView editView = getEditView(feature, name, type, value); LinearLayout.LayoutParams editViewParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); editViewParams.setMargins(margin, 0, margin, 0); editView.setLayoutParams(editViewParams); editView.setPadding(padding * 2, padding, padding * 2, padding); editView.setFocusable(!isReadOnly); if (isReadOnly) { editView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { String text = editView.getText().toString(); FeatureUtilities.viewIfApplicable(v.getContext(), text); return false; } }); } linearLayoutView.addView(editView); } /* * add also area and length */ if (feature.getOriginalArea() > -1) { TextView areaTextView = new TextView(context); areaTextView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); areaTextView.setPadding(padding, padding, padding, padding); areaTextView.setText(context.getString(eu.geopaparazzi.core.R.string.area_colon) + areaLengthFormatter.format(feature.getOriginalArea())); areaTextView.setTextColor(textColor); TextView lengthTextView = new TextView(context); lengthTextView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); lengthTextView.setPadding(padding, padding, padding, padding); lengthTextView.setText(context.getString(eu.geopaparazzi.core.R.string.length_colon) + areaLengthFormatter.format(feature.getOriginalLength())); lengthTextView.setTextColor(textColor); linearLayoutView.addView(areaTextView); linearLayoutView.addView(lengthTextView); } container.addView(scrollView); return scrollView; }
From source file:com.ranger.bmaterials.view.PagerSlidingTabStrip.java
private void addTextTab(final int position, final String title) { TextView tab = new TextView(getContext()); tab.setText(title);// w ww . j a v a 2 s. com tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (clickListener != null) clickListener.onClick(position, title); pager.setCurrentItem(position, false); currentPosition = position; currentPositionOffset = 0; scrollToChild(position, 0); invalidate(); } }); tabsContainer.addView(tab); }
From source file:com.cssweb.android.quote.QHSCGridActivity.java
private void AddViewItem(int paramInt1, LinearLayout paramLinearLayout, int paramInt2, int paramInt3, int paramInt4, boolean paramBoolean) { TextView localTextView = new TextView(this); float f = this.mFontSize; localTextView.setTextSize(f);/*w w w . j av a 2s .c om*/ localTextView.setGravity(Gravity.CENTER); localTextView.setFocusable(paramBoolean); localTextView.setOnClickListener(mClickListener); localTextView.setOnLongClickListener(mLongClickListener); localTextView.setOnTouchListener(this); // touch localTextView.setTag(paramInt2); localTextView.setEnabled(paramBoolean); localTextView.setSingleLine(true); Resources localResources = getResources(); Drawable localDrawable = null; if (paramInt4 == 0 && paramInt3 >= 0) {// int i1 = this.residTitleCol; int i8 = 0; localTextView.setTextColor(paramInt1); if (paramInt3 == 0) { localDrawable = localResources.getDrawable(i1); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 100) { localDrawable = localResources.getDrawable(this.residTitleScrollCol[2]); i8 = localDrawable.getIntrinsicWidth(); i8 += 20; } else if (paramInt3 == 13) { localDrawable = localResources.getDrawable(this.residTitleScrollCol[0]); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 % 2 == 0) { localDrawable = localResources.getDrawable(this.residTitleScrollCol[1]); i8 = localDrawable.getIntrinsicWidth(); } else { localDrawable = localResources.getDrawable(this.residTitleScrollCol[0]); i8 = localDrawable.getIntrinsicWidth(); } localTextView.setBackgroundDrawable(localDrawable); int i6 = localDrawable.getIntrinsicHeight(); localTextView.setHeight(i6 + CssSystem.getTableTitleHeight(this)); localTextView.setWidth(i8); paramLinearLayout.addView(localTextView); return; } if (paramInt4 != 0 && paramInt3 >= 0) { int i8 = 0; localTextView.setTextColor(paramInt1); if (paramInt3 == 0) { localDrawable = localResources.getDrawable(this.residCol); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 100) { localDrawable = localResources.getDrawable(this.residScrollCol[2]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); i8 += 20; } else if (paramInt3 == 13) { localDrawable = localResources.getDrawable(this.residScrollCol[0]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 % 2 == 0) { localDrawable = localResources.getDrawable(this.residScrollCol[1]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } else { localDrawable = localResources.getDrawable(this.residScrollCol[0]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } localTextView.setBackgroundDrawable(localDrawable); int i6 = localDrawable.getIntrinsicHeight(); localTextView.setHeight(i6 + rowHeight); localTextView.setWidth(i8); paramLinearLayout.addView(localTextView); return; } }
From source file:jahirfiquitiva.iconshowcase.adapters.ChangelogAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { LayoutInflater inflater = LayoutInflater.from(context); convertView = inflater.inflate(R.layout.changelog_content, parent, false); convertView.setClickable(false); convertView.setLongClickable(false); convertView.setFocusable(false); convertView.setFocusableInTouchMode(false); convertView.setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent)); }//from www .j a v a 2 s . c o m TextView title = (TextView) convertView.findViewById(R.id.changelog_title); TextView content = (TextView) convertView.findViewById(R.id.changelog_content); String nameStr = mChangelog[position][0]; String contentStr = ""; for (int i = 1; i < mChangelog[position].length; i++) { if (i > 1) { // No need for new line on the first item contentStr += "\n"; } contentStr += "\u2022 "; contentStr += mChangelog[position][i]; } title.setText(nameStr); title.setClickable(false); title.setLongClickable(false); title.setFocusable(false); title.setFocusableInTouchMode(false); title.setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent)); content.setText(contentStr); content.setClickable(false); content.setLongClickable(false); content.setFocusable(false); content.setFocusableInTouchMode(false); content.setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent)); return convertView; }
From source file:com.android.yijiang.kzx.widget.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext(), null, android.R.attr.textAppearanceMedium); tab.setText(title);//from www . jav a2s . c om tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tab); }
From source file:com.cmax.bodysheild.widget.PagerSlidingTabStripExtends.java
public void setAllTabTextColor(int res) { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); if (v instanceof TextView) { TextView tv = (TextView) v; tv.setTextColor(res);//from w ww .j av a 2s . com tv.setClickable(true); tv.setEnabled(true); tv.setFocusable(true); } } }
From source file:cn.org.eshow.framwork.view.sliding.AbSlidingSmoothFixTabView.java
/** * ??tab.// w ww. j a va 2s. 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:cn.org.eshow.framwork.view.sliding.AbSlidingSmoothFixTabView.java
/** * ??tab./*www .j a va 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); }