List of usage examples for android.widget TextView TextView
public TextView(Context context)
From source file:app.daeng.tokped.Utils.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;// w w w . ja 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)); 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); } } // First spacer tab TextView firstTab = new TextView(getContext()); mTabStrip.addView(firstTab, 0); // Last spacer tab TextView lastTab = new TextView(getContext()); mTabStrip.addView(lastTab); }
From source file:cn.mailchat.view.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { //layout/*w ww.j a va 2 s.com*/ RelativeLayout tabLayout = new RelativeLayout(getContext()); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tabLayout.setLayoutParams(layoutParams); RelativeLayout.LayoutParams textParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); textParams.addRule(RelativeLayout.CENTER_IN_PARENT); //tab TextView tab = new TextView(getContext()); tab.setId(100 + position); tab.setText(title); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tabLayout.addView(tab, textParams); //??? RelativeLayout.LayoutParams viewParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); viewParams.addRule(RelativeLayout.RIGHT_OF, tab.getId()); viewParams.addRule(RelativeLayout.CENTER_VERTICAL); View view = new View(getContext()); ViewGroup.LayoutParams vParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); view.setLayoutParams(vParams); tabLayout.addView(view, viewParams); addTab(position, tabLayout); }
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);//w ww.j a v a 2 s . co m 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.binomed.showtime.android.screen.movie.CineShowTimeMovieFragment.java
private void createTabs(View mainView) { try {//from www .ja va 2 s . co m tabHost = (TabHost) mainView.findViewById(android.R.id.tabhost); tabWidget = (TabWidget) mainView.findViewById(android.R.id.tabs); // tabHost = getTabHost(); // tabWidget = getTabWidget(); tabHost.setup(); tabHost.getTabWidget().setDividerDrawable(R.drawable.cst_tab_divider); Intent intentEmptyActivity = new Intent(interaction.getMainContext(), EmptyActivity.class); // TextView txt = new TextView(getActivity()); // txt.setCompoundDrawables(left, top, right, bottom); // txt.setBackgroundResource(resid); TabHost.TabSpec tabSummary = tabHost.newTabSpec("Summary"); // tabSummary.setContent(intentEmptyActivity); tabSummary.setContent(new TabHost.TabContentFactory() { @Override public View createTabContent(String arg0) { TextView view = new TextView(interaction.getMainContext()); return view; } }); View viewInfo = LayoutInflater.from(interaction.getMainContext()).inflate(R.layout.view_tab_item, null); TextView tvInfo = (TextView) viewInfo.findViewById(R.id.title); tvInfo.setText(R.string.movieLabel); ImageView ivInfo = (ImageView) viewInfo.findViewById(R.id.icon); ivInfo.setBackgroundResource(R.drawable.ic_tab_info); tabSummary.setIndicator(viewInfo); // tabSummary.setIndicator(getResources().getString(R.string.movieLabel).toUpperCase(), getResources().getDrawable(R.drawable.ic_tab_info)); TabHost.TabSpec tabProjection = tabHost.newTabSpec("Projection"); // tabProjection.setContent(intentEmptyActivity); tabProjection.setContent(new TabHost.TabContentFactory() { @Override public View createTabContent(String arg0) { TextView view = new TextView(interaction.getMainContext()); return view; } }); View viewShowTimes = LayoutInflater.from(interaction.getMainContext()).inflate(R.layout.view_tab_item, null); TextView tvShowTimes = (TextView) viewShowTimes.findViewById(R.id.title); tvShowTimes.setText(R.string.showtimeLabel); ImageView ivShowTimes = (ImageView) viewShowTimes.findViewById(R.id.icon); ivShowTimes.setBackgroundResource(R.drawable.ic_tab_showtimes); tabProjection.setIndicator(viewShowTimes); // tabProjection.setIndicator(getResources().getString(R.string.showtimeLabel).toUpperCase(), getResources().getDrawable(R.drawable.ic_tab_showtimes)); TabHost.TabSpec tabReviews = tabHost.newTabSpec("Review"); // tabReviews.setContent(intentEmptyActivity); tabReviews.setContent(new TabHost.TabContentFactory() { @Override public View createTabContent(String arg0) { TextView view = new TextView(interaction.getMainContext()); return view; } }); View viewReviews = LayoutInflater.from(interaction.getMainContext()).inflate(R.layout.view_tab_item, null); TextView tvReviews = (TextView) viewReviews.findViewById(R.id.title); tvReviews.setText(R.string.rateLabel); ImageView ivReviews = (ImageView) viewReviews.findViewById(R.id.icon); ivReviews.setBackgroundResource(R.drawable.ic_tab_review); tabReviews.setIndicator(viewReviews); // tabReviews.setIndicator(getResources().getString(R.string.rateLabel).toUpperCase(), getResources().getDrawable(R.drawable.ic_tab_review)); tabHost.addTab(tabSummary); tabHost.addTab(tabProjection); tabHost.addTab(tabReviews); // tabHost.setCurrentTab(model.getLastTab()); } catch (Exception e1) { Log.e(TAG, "error while init Movie acitivty", e1); //$NON-NLS-1$ } }
From source file:cn.org.eshow.framwork.view.sliding.AbSlidingSmoothFixTabView.java
/** * ??tab./*from w w w.j a v a 2 s. co 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); } }); } //? AbLogUtil.d(AbSlidingSmoothFixTabView.class, "addItemView finish"); mFragmentPagerAdapter.notifyDataSetChanged(); mViewPager.setCurrentItem(0); computeTabImg(0); }
From source file:com.bangqu.eshow.view.sliding.ESSlidingSmoothFixTabView.java
/** * ??tab.//from w w w . j a v a 2s .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); } }); } //? ESLogUtil.d(ESSlidingSmoothFixTabView.class, "addItemView finish"); mFragmentPagerAdapter.notifyDataSetChanged(); mViewPager.setCurrentItem(0); computeTabImg(0); }
From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java
@Override public void onCreate() { mRecordingTimeView = new TextView(ApplicationScreen.getMainContext()); mRecordingTimeView.setTextSize(12);/*w w w . j a v a 2 s .c o m*/ mRecordingTimeView.setBackgroundResource(R.drawable.thumbnail_background); mRecordingTimeView.setVisibility(View.GONE); mRecordingTimeView.setGravity(Gravity.CENTER); mRecordingTimeView.setText("00:00"); this.createModeSwitcher(); if (VERSION.SDK_INT < VERSION_CODES.JELLY_BEAN_MR2) { this.modeSwitcher.setVisibility(View.GONE); } }
From source file:com.cmax.bodysheild.widget.PagerSlidingTabStripExtends.java
public void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);/* w w w . ja v a 2 s . c o m*/ tab.setGravity(Gravity.CENTER); tab.setSingleLine(); addTab(position, tab); }
From source file:com.abid_mujtaba.fetchheaders.fragments.AccountFragment.java
private void setErrorView(String error_message) // Method for creating and displaying an Error Message View. { // TODO: Create a custom layout for Error TextViews in general to be used in such cases. Possibly add a triangular icon indicating an error. TextView tv = new TextView(getActivity()); tv.setText(error_message);/*w w w . j a va 2 s. c o m*/ tv.setTextColor(getResources().getColor(R.color.red)); mEmailList.addView(tv); }
From source file:fr.cph.chicago.activity.BusActivity.java
/** * Draw arrivals in current layout/*from w w w . j ava 2s . c om*/ */ public final void drawArrivals() { if (mBusArrivals != null) { Map<String, TextView> mapRes = new HashMap<String, TextView>(); if (this.mBusArrivals.size() != 0) { for (BusArrival arrival : this.mBusArrivals) { if (arrival.getRouteDirection().equals(mBound)) { String destination = arrival.getBusDestination(); if (mapRes.containsKey(destination)) { TextView arrivalView = mapRes.get(destination); if (arrival.getIsDly()) { arrivalView.setText(arrivalView.getText() + " Delay"); } else { arrivalView.setText(arrivalView.getText() + " " + arrival.getTimeLeft()); } } else { TextView arrivalView = new TextView(ChicagoTracker.getAppContext()); if (arrival.getIsDly()) { arrivalView.setText(arrival.getBusDestination() + ": Delay"); } else { arrivalView.setText(arrival.getBusDestination() + ": " + arrival.getTimeLeft()); } arrivalView.setTextColor( ChicagoTracker.getAppContext().getResources().getColor(R.color.grey)); mapRes.put(destination, arrivalView); } } } } else { TextView arrivalView = new TextView(ChicagoTracker.getAppContext()); arrivalView.setTextColor(ChicagoTracker.getAppContext().getResources().getColor(R.color.grey)); arrivalView.setText("No service scheduled"); mapRes.put("", arrivalView); } mStopsView.removeAllViews(); for (Entry<String, TextView> entry : mapRes.entrySet()) { mStopsView.addView(entry.getValue()); } } }