List of usage examples for android.widget TextView setMaxLines
@android.view.RemotableViewMethod public void setMaxLines(int maxLines)
From source file:org.comixwall.pffw.InfoHosts.java
/** * Change the size of certain text views on touch if the content does not fit. * * @param view Container view//from w ww .j a v a2 s. c o m */ @Override public void onItemClick(View view) { TextView tvCommand = view.findViewById(R.id.command); TextView tvUserGroup = view.findViewById(R.id.others); int lines = 10; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { if (tvCommand.getMaxLines() != 1) { lines = 1; } } tvCommand.setMaxLines(lines); tvUserGroup.setMaxLines(lines); }
From source file:com.google.android.common.view.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}./*from w w w . j av a2 s . c om*/ */ 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.setMaxLines(1); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:org.mythdroid.activities.Guide.java
/** * Generate a TableRow from the provided Channel * @param ch Channel to generate a row for * @return populated TableRow representing the channel *//*from ww w . j a v a2s. co m*/ @SuppressLint("DefaultLocale") private TableRow getRowFromChannel(Channel ch) { final TableRow row = new TableRow(this); row.setLayoutParams(rowLayout); TextView tv = new TextView(this); tv.setBackgroundColor(0xffe0e0f0); tv.setTextColor(0xff202020); tv.setPadding(4, 4, 4, 4); tv.setMaxLines(2); tv.setTag(ch.ID); tv.setText(ch.num + " " + ch.callSign); //$NON-NLS-1$ tv.setOnClickListener(chanClickListener); tv.setOnLongClickListener(chanLongClickListener); tv.setLayoutParams(chanLayout); row.addView(tv); LayoutParams layout = null; Program[] progs = ch.programs.toArray(new Program[ch.programs.size()]); int numprogs = progs.length; for (int i = 0; i < numprogs; i++) { if (progs[i].StartTime.equals(later)) continue; tv = new TextView(this); layout = new LayoutParams(this, null); layout.topMargin = layout.bottomMargin = layout.leftMargin = layout.rightMargin = 1; layout.height = rowHeight; String cat = catPat.matcher(progs[i].Category.toLowerCase()).replaceAll(""); //$NON-NLS-1$ try { tv.setBackgroundColor(Category.valueOf(cat).color()); } catch (IllegalArgumentException e) { tv.setBackgroundColor(Category.unknown.color()); } tv.setTextColor(0xfff0f0f0); tv.setPadding(4, 4, 4, 4); tv.setMaxLines(2); tv.setText(progs[i].Title); setStatusDrawable(tv, progs[i]); int width = setLayoutParams(layout, progs[i]) * colWidth; if (width < 1) continue; tv.setWidth(width); tv.setLayoutParams(layout); tv.setTag(progs[i]); tv.setOnClickListener(progClickListener); row.addView(tv); } return row; }
From source file:org.mythdroid.activities.Guide.java
/** * Get a header row containing column time values * @return header TableRow//from ww w . j av a 2 s .co m */ private TableRow getHeader() { final TableRow row = new TableRow(this, null); TextView tv = new TextView(this, null); tv.setLayoutParams(hdrDateLayout); tv.setPadding(4, 4, 4, 4); tv.setBackgroundColor(0xffd0d0ff); tv.setTextColor(0xff161616); tv.setMaxLines(1); tv.setText(hdrDate); row.addView(tv); int j = 0; for (int i = 1; i < times.length; i += hdrSpan) { tv = new TextView(this, null); tv.setLayoutParams(hdrTimeLayout); tv.setPadding(4, 4, 4, 4); tv.setBackgroundColor(0xffd0d0ff); tv.setTextColor(0xff161616); tv.setMaxLines(1); tv.setText(hdrTimes[j++]); row.addView(tv); } return row; }
From source file:com.hypodiabetic.happ.MainActivity.java
public void showAlgorithmJSON(View view) { Date dateVar = new Date(); Profile profileNow = new Profile(dateVar, view.getContext()); //Shows the JSON output of the selected Algorithm String rawAPSJSON = APS.rawJSON(view.getContext(), profileNow).toString(); Snackbar snackbar = Snackbar.make(view, "RAW JSON: " + rawAPSJSON, Snackbar.LENGTH_INDEFINITE); View snackbarView = snackbar.getView(); TextView textView = (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text); textView.setMaxLines(5); //set the max lines for textview to show multiple lines snackbar.show();// ww w . j a v a 2s.c o m ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); clipboard.setText(rawAPSJSON); Toast.makeText(view.getContext(), "Raw JSON sent to clipboard", Toast.LENGTH_SHORT).show(); }
From source file:com.android.nsboc.ComposeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (mItem != null) { switch (mItem.id + "") { case "1": mRootView = inflater.inflate(R.layout.form_unlicensed, container, false); break; case "2": mRootView = inflater.inflate(R.layout.form_salon, container, false); break; }/* www . ja v a2 s. c o m*/ } showCurrentDateInEditText(); ToggleButton complianceToggle = (ToggleButton) mRootView.findViewById(R.id.compliance_toggle); if (complianceToggle != null) { final LinearLayout complianceContainer = (LinearLayout) mRootView .findViewById(R.id.compliance_container); complianceToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (!isChecked) { complianceContainer.setVisibility(View.VISIBLE); final LinearLayout complianceLayout = (LinearLayout) View.inflate(getActivity(), R.layout.compliance_layout, null); Spinner violationTypeSpinner = (Spinner) complianceLayout .findViewById(R.id.violation_type_spinner); violationTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: complianceLayout.findViewById(R.id.type_citation_container) .setVisibility(View.VISIBLE); break; case 1: complianceLayout.findViewById(R.id.type_citation_container) .setVisibility(View.GONE); break; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); ToggleButton anotherToggle = (ToggleButton) complianceLayout .findViewById(R.id.compliance_toggle); anotherToggle.setOnCheckedChangeListener(getNextToggleListener(complianceLayout)); complianceContainer.addView(complianceLayout); } else { complianceContainer.setVisibility(View.GONE); } } }); } ToggleButton emailToggle = (ToggleButton) mRootView.findViewById(R.id.emailTo_toggle); if (emailToggle != null) { final LinearLayout emailLayout = (LinearLayout) mRootView.findViewById(R.id.emailTo_layout); emailToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { emailLayout.setVisibility(View.VISIBLE); } else { emailLayout.setVisibility(View.GONE); } } }); } final TextView noticeTextView = (TextView) mRootView.findViewById(R.id.notice_textview); if (noticeTextView != null) { noticeTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (noticeTextView.getCurrentTextColor() == Color.BLACK) { noticeTextView.setText(R.string.civil_citation_header); noticeTextView.setTextColor(Color.parseColor("#17405e")); noticeTextView.setText(Html.fromHtml("<u>" + noticeTextView.getText() + "</u>")); mRootView.findViewById(R.id.civil_citation).requestFocus(); } else { noticeTextView.setText(R.string.civil_citation_notice); noticeTextView.setMaxLines(Integer.MAX_VALUE); noticeTextView.setTextColor(Color.BLACK); noticeTextView.setText( noticeTextView.getText().toString().replace("<u>", "").replace("</u>", "")); } } }); } Spinner stateSpinner = (Spinner) mRootView.findViewById(R.id.state); if (stateSpinner != null) { stateSpinner.setSelection(27); } return mRootView; }
From source file:com.keylesspalace.tusky.activity.MainActivity.java
private void setupSearchView() { searchView.attachNavigationDrawerToMenuButton(drawer.getDrawerLayout()); searchView.setOnQueryChangeListener(new FloatingSearchView.OnQueryChangeListener() { @Override/*w ww. j a v a2 s .c om*/ public void onSearchTextChanged(String oldQuery, String newQuery) { if (!oldQuery.equals("") && newQuery.equals("")) { searchView.clearSuggestions(); return; } if (newQuery.length() < 3) { return; } searchView.showProgress(); mastodonAPI.searchAccounts(newQuery, false, 5).enqueue(new Callback<List<Account>>() { @Override public void onResponse(Call<List<Account>> call, Response<List<Account>> response) { if (response.isSuccessful()) { searchView.swapSuggestions(response.body()); searchView.hideProgress(); } else { searchView.hideProgress(); } } @Override public void onFailure(Call<List<Account>> call, Throwable t) { searchView.hideProgress(); } }); } }); searchView.setOnSearchListener(new FloatingSearchView.OnSearchListener() { @Override public void onSuggestionClicked(SearchSuggestion searchSuggestion) { Account accountSuggestion = (Account) searchSuggestion; Intent intent = new Intent(MainActivity.this, AccountActivity.class); intent.putExtra("id", accountSuggestion.id); startActivity(intent); } @Override public void onSearchAction(String currentQuery) { } }); searchView.setOnBindSuggestionCallback(new SearchSuggestionsAdapter.OnBindSuggestionCallback() { @Override public void onBindSuggestion(View suggestionView, ImageView leftIcon, TextView textView, SearchSuggestion item, int itemPosition) { Account accountSuggestion = ((Account) item); Picasso.with(MainActivity.this).load(accountSuggestion.avatar) .placeholder(R.drawable.avatar_default).into(leftIcon); String searchStr = accountSuggestion.getDisplayName() + " " + accountSuggestion.username; final SpannableStringBuilder str = new SpannableStringBuilder(searchStr); str.setSpan(new StyleSpan(Typeface.BOLD), 0, accountSuggestion.getDisplayName().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(str); textView.setMaxLines(1); textView.setEllipsize(TextUtils.TruncateAt.END); } }); }
From source file:dev.journey.uitoolkit.view.FlexibleTabLayout.java
private TextView getDefaultTextView() { TextView textView = new TextView(getContext()); textView.setMaxLines(2); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setGravity(Gravity.CENTER); LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); textView.setLayoutParams(layoutParams); return textView; }
From source file:com.demo.panguso.demo160714.view.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); frgCount = adapter.getCount();//from w w w .j a v a2 s .c om for (int i = 0; i < adapter.getCount(); i++) { View tabView = null; 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.setTextSize(tabTitleTextSize); tabTitleView.setMaxLines(1); tabView.setOnClickListener(new TabClickListener()); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } textViewList.add(tabTitleView); } textViewList.get(0).setTextColor(selectedTitleTextColor); for (int i = 1; i < frgCount; i++) { textViewList.get(i).setTextColor(unselectedTitleTextColor); } }
From source file:com.android.loushi.loushi.util.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); frgCount = adapter.getCount();/*from w w w . jav a2s .c o m*/ for (int i = 0; i < adapter.getCount(); i++) { View tabView = null; 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.setTextSize(tabTitleTextSize); tabTitleView.setMaxLines(1); tabView.setOnClickListener(new TabClickListener()); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } TextView tv_collect_cate = (TextView) tabView.findViewById(R.id.tv_tab_view_cate); if (i == 0) tv_collect_cate.setText(""); if (i == 1) tv_collect_cate.setText("?"); mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } textViewList.add(tabTitleView); } textViewList.get(0).setTextColor(selectedTitleTextColor); for (int i = 1; i < frgCount; i++) { textViewList.get(i).setTextColor(unselectedTitleTextColor); } }