List of usage examples for android.widget TextView TextView
public TextView(Context context)
From source file:ch.pantas.billsplitter.ui.FixedTabsView.java
private void addTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);//from ww w . j a v a 2 s.c om tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1f)); tab.setFocusable(true); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { viewPager.setCurrentItem(position); } }); tabsContainer.addView(tab, position); }
From source file:ch.heigvd.wordhunt.Interaction.FloatLabelLayout.java
public void init(Context context, AttributeSet attrs) { setOrientation(VERTICAL);/*from w w w .j a v a 2 s . c o m*/ final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatLabelLayout); int leftPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingLeft, dipsToPix(DEFAULT_LABEL_PADDING_LEFT)); int topPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingTop, dipsToPix(DEFAULT_LABEL_PADDING_TOP)); int rightPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingRight, dipsToPix(DEFAULT_LABEL_PADDING_RIGHT)); int bottomPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingBottom, dipsToPix(DEFAULT_LABEL_PADDING_BOTTOM)); mHint = a.getText(R.styleable.FloatLabelLayout_floatLabelHint); mLabel = new TextView(context); mLabel.setPadding(leftPadding, topPadding, rightPadding, bottomPadding); mLabel.setVisibility(INVISIBLE); mLabel.setText(mHint); ViewCompat.setPivotX(mLabel, 0f); ViewCompat.setPivotY(mLabel, 0f); mLabel.setTextAppearance(context, a.getResourceId(R.styleable.FloatLabelLayout_floatLabelTextAppearance, android.R.style.TextAppearance_Small)); a.recycle(); addView(mLabel, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); mInterpolator = AnimationUtils.loadInterpolator(context, Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? android.R.interpolator.fast_out_slow_in : android.R.anim.decelerate_interpolator); }
From source file:com.axum.darivb.searchview.SlidingTabLayout.java
protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(bariol_regular_tf); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); }//from w w w. j a v a 2s .co m if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.InviteToGroupObj.java
@Override public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();/*from www . j av a 2 s. com*/ TextView valueTV = new TextView(context); valueTV.setText("Join me in '" + content.optString(GROUP_NAME) + "'"); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); frame.addView(valueTV); }
From source file:at.flack.FacebookMainActivity.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (((MainActivity) getActivity()).existsCookie()) { View rootView = inflater.inflate(R.layout.fragment_fb_main, container, false); contactList = (ListView) rootView.findViewById(R.id.listview); loadmore = new LoadMoreAdapter(inflater.inflate(R.layout.contacts_loadmore, contactList, false)); cantloadContacts = rootView.findViewById(R.id.nothing_found); TextView padding = new TextView(getActivity()); padding.setHeight(10);//w w w . j av a 2 s . com contactList.addHeaderView(padding); contactList.setHeaderDividersEnabled(false); contactList.addFooterView(loadmore.getView(), null, false); contactList.setFooterDividersEnabled(false); smiley_helper = new SmileyKonverter(); swipe = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_container); swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { if (getActivity() instanceof MainActivity) ((MainActivity) getActivity()).facebookLogin(); } }); contactList.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { int topRowVerticalPosition = (contactList == null || contactList.getChildCount() == 0) ? 0 : contactList.getChildAt(0).getTop(); swipe.setEnabled(topRowVerticalPosition >= 0); } }); loadmore.getView().setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { loadmore.setEnabled(false); loadMore(); } }); setProgressbar(rootView.findViewById(R.id.load_screen)); if (MainActivity.getFbcontacts() == null) getProgressbar().setVisibility(View.VISIBLE); updateContacts(getActivity()); contactList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { openMessageActivity(getActivity(), arg2 - 1); } }); FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab); fab.attachToListView(contactList); fab.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent qr = new Intent(getActivity(), NewFbContactActivity.class); startActivityForResult(qr, 1); } }); updateProfilePictures(getActivity()); setRetainInstance(true); return rootView; } else { View rootView = inflater.inflate(R.layout.fragment_facebook_login, container, false); final EditText mail = (EditText) rootView.findViewById(R.id.email); final EditText password = (EditText) rootView.findViewById(R.id.password); final Button login_button = (Button) rootView.findViewById(R.id.login_button); login_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mail.getText().length() <= 0) { Toast.makeText(FacebookMainActivity.this.getActivity(), getResources().getString(R.string.facebook_login_please_enter_valid_mail), Toast.LENGTH_SHORT).show(); return; } if (password.getText().length() <= 0) { Toast.makeText(FacebookMainActivity.this.getActivity(), getResources().getString(R.string.facebook_login_please_enter_valid_pw), Toast.LENGTH_SHORT).show(); return; } login_button.setEnabled(false); login_button.getBackground().setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY); if (((MainActivity) getActivity()).facebookLogin(mail.getText().toString(), password.getText().toString())) { } else { Toast.makeText(FacebookMainActivity.this.getActivity(), getResources().getString(R.string.facebook_login_incorrect_or_offline), Toast.LENGTH_SHORT).show(); password.setText(""); login_button.getBackground().setColorFilter(null); login_button.setEnabled(true); } } }); setRetainInstance(true); return rootView; } }
From source file:com.android.purenexussettings.utils.SlidingTabLayout.java
protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, getResources().getInteger(R.integer.slidetab_view_text_size_sp)); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true);//from ww w. j a v a2s. c o m // some fudging around for padding of the tabs int paddingtb = (int) (getResources().getInteger(R.integer.slidetab_view_top_padding_dips) * getResources().getDisplayMetrics().density); int paddinglr = (int) (getResources().getInteger(R.integer.slidetab_view_padding_dips) * getResources().getDisplayMetrics().density); textView.setPadding(paddinglr, paddingtb, paddinglr, paddingtb); return textView; }
From source file:edu.cwru.apo.Directory.java
private void loadTable() { ProgressDialog progDialog = ProgressDialog.show(this, "Loading", "Please Wait", false); userTable.removeAllViews();// w w w . j a va 2 s.com Cursor results = database.query("phoneDB", new String[] { "first", "last", "_id", "phone" }, null, null, null, null, "first"); String rowText = ""; TableRow row; TextView text; if (!results.moveToFirst()) return; while (!results.isAfterLast()) { String phoneNumber = removeNonDigits(results.getString(3)); if (!(phoneNumber == null || phoneNumber.trim().equals("") || phoneNumber.trim().equals("null"))) { rowText = results.getString(0) + " " + results.getString(1) + " [" + results.getString(2) + "]"; row = new TableRow(this); text = new TextView(this); row.setPadding(0, 5, 0, 5); text.setClickable(true); text.setOnClickListener(this); //text.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); text.setText(rowText); userTable.addView(row); row.addView(text); } results.moveToNext(); } progDialog.cancel(); }
From source file:com.chaos.dmactiontabsexample.view.SlidingTabLayout.java
protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true);/* w w w.j av a2 s . c o m*/ int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.aboveware.abovegame.expandable.ExpandableListFragment.java
/** * Provide default implementation to return a simple list view. Subclasses can * override to replace with their own layout. If doing so, the returned view * hierarchy <em>must</em> have a ListView whose id is * {@link android.R.id#list android.R.id.list} and can optionally have a * sibling view id {@link android.R.id#empty android.R.id.empty} that is to be * shown when the list is empty./*from w ww .jav a 2s .c o m*/ * <p/> * <p> * If you are overriding this method with your own custom content, consider * including the standard layout {@link android.R.layout#list_content} in your * layout file, so that you continue to retain all of the standard behavior of * AbsListFragment. In particular, this is currently the only way to have the * built-in indeterminant progress state be shown. */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { FrameLayout root = new FrameLayout(getActivity()); FrameLayout lframe = new FrameLayout(getActivity()); lframe.setId(INTERNAL_LIST_CONTAINER_ID); TextView tv = new TextView(getActivity()); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); ExpandableListView lv = new ExpandableListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); ListView.LayoutParams lp = new ListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); root.setLayoutParams(lp); return root; }
From source file:com.baoyz.bigbang.BigBangLayout.java
public void addTextItem(String text) { TextView view = new TextView(getContext()); view.setText(text);//from w ww . java2 s . c o m view.setBackgroundResource(R.drawable.item_background); view.setTextColor(ContextCompat.getColorStateList(getContext(), R.color.bigbang_item_text)); view.setGravity(Gravity.CENTER); addView(view); }