List of usage examples for android.widget TextView getTypeface
public Typeface getTypeface()
From source file:com.cyanogenmod.eleven.widgets.ViewPagerTabs.java
private void addTab(CharSequence tabTitle, final int position) { final TextView textView = new TextView(getContext()); textView.setText(tabTitle);//from w w w. j a v a 2s .c om textView.setBackgroundResource(R.drawable.view_pager_tab_background); textView.setGravity(Gravity.CENTER); textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mPager.setCurrentItem(getRtlPosition(position)); } }); textView.setOnLongClickListener(new OnTabLongClickListener(position)); // Assign various text appearance related attributes to child views. if (mTextStyle > 0) { textView.setTypeface(textView.getTypeface(), mTextStyle); } if (mTextSize > 0) { textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); } if (mTextColor != null) { textView.setTextColor(mTextColor); } textView.setAllCaps(mTextAllCaps); textView.setPadding(mSidePadding, 0, mSidePadding, 0); mTabStrip.addView(textView, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1)); // Default to the first child being selected if (position == 0) { mPrevSelected = 0; textView.setSelected(true); } }
From source file:nccp.app.ui.ViewPagerTabs.java
private void addTab(CharSequence tabTitle, final int position) { final TextView textView = new TextView(getContext()); textView.setText(tabTitle);/*from www.j a va 2 s . c o m*/ textView.setBackgroundResource(R.drawable.view_pager_tab_background); textView.setGravity(Gravity.CENTER); textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mPager.setCurrentItem(getRtlPosition(position)); } }); textView.setOnLongClickListener(new OnTabLongClickListener(position)); // Assign various text appearance related attributes to child views. if (mTextStyle > 0) { textView.setTypeface(textView.getTypeface(), mTextStyle); } if (mTextSize > 0) { textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); } if (mTextColor != null) { textView.setTextColor(mTextColor); } // textView.setAllCaps(mTextAllCaps); textView.setPadding(mSidePadding, 0, mSidePadding, 0); mTabStrip.addView(textView, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1)); // Default to the first child being selected if (position == 0) { mPrevSelected = 0; textView.setSelected(true); } }
From source file:com.frozendevs.periodictable.view.ViewPagerTabs.java
private void addTab(CharSequence tabTitle, final int position) { final TextView textView = new TextView(getContext()); textView.setText(tabTitle);//w w w . jav a2s.co m textView.setGravity(Gravity.CENTER); textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mPager.setCurrentItem(getRtlPosition(position)); } }); /* We don't need this as far as we use text tabs only textView.setOnLongClickListener(new OnTabLongClickListener(position));*/ // Assign various text appearance related attributes to child views. if (mTextStyle > 0) { textView.setTypeface(textView.getTypeface(), mTextStyle); } if (mTextSize > 0) { textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); } if (mTextColor != null) { textView.setTextColor(mTextColor); } if (mTextBackground > 0) { textView.setBackgroundResource(mTextBackground); } textView.setText( textView.getText().toString().toUpperCase(getContext().getResources().getConfiguration().locale)); textView.setPadding(mSidePadding, 0, mSidePadding, 0); mTabStrip.addView(textView, new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1)); // Default to the first child being selected if (position == 0) { mPrevSelected = 0; textView.setSelected(true); } }
From source file:com.dmbstream.android.adapter.ConcertListAdapter.java
@Override public View getView(final int position, View convertView, final ViewGroup parent) { if (convertView == null) { convertView = inflater.inflate(R.layout.partial_concert_list_item, parent, false); }/*from ww w .j a v a 2 s.co m*/ Concert concert = getItem(position); TextView date = (TextView) convertView.findViewById(R.id.ConcertItemDate); TextView artist = (TextView) convertView.findViewById(R.id.ConcertItemArtist); TextView name = (TextView) convertView.findViewById(R.id.ConcertItemName); if (concert != null) { Date d = new Date(concert.date.getTimeInMillis()); DateFormat shortDateFormat = new SimpleDateFormat("yyyy-MM-dd"); date.setText(shortDateFormat.format(d)); artist.setText(concert.artistAbbreviation); name.setText(concert.name); // Need to (re)set this because the views are reused. If we don't // then // while scrolling, some items will replace the old // "Load more concerts" // view and will be in italics name.setTypeface(name.getTypeface(), Typeface.BOLD); date.setVisibility(View.VISIBLE); artist.setVisibility(View.VISIBLE); } else { // null marker means it's the end of the list. name.setTypeface(name.getTypeface(), Typeface.ITALIC); name.setText(R.string.msg_load_more_concerts); date.setVisibility(View.GONE); artist.setVisibility(View.GONE); } return convertView; }
From source file:org.appcelerator.titanium.util.TiUIHelper.java
public static String getDefaultFontWeight(final Context context) { String style = "normal"; TextView tv = new TextView(context); if (tv != null) { Typeface tf = tv.getTypeface(); if (tf != null && tf.isBold()) { style = "bold"; }/*from w w w . j a v a2 s . c om*/ } return style; }
From source file:com.pukulab.puku0x.gscalendar.CalendarActivity.java
@Override public void onDayClick(final long dayInMillis) { // Reset the previously selected TextView to his previous Typeface if (mSelectedTextView != null) { mSelectedTextView.setTypeface(mSelectedTypeface); mSelectedTextView.setBackgroundColor(getResources().getColor(android.R.color.background_light)); }//from ww w. j ava 2s . co m final TextView day = mCalendarView.getTextViewForDate(dayInMillis); if (day != null) { // Remember the selected TextView and it's font mSelectedTypeface = day.getTypeface(); mSelectedTextView = day; // Show the selected TextView as bold day.setTypeface(Typeface.DEFAULT_BOLD); day.setBackgroundColor(getResources().getColor(R.color.theme_color_transparent)); } // ? Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(dayInMillis); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); mDisplayedDate = calendar.getTime(); // ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { //actionBar.setDisplayHomeAsUpEnabled(true); //actionBar.setTitle(mDisplayedUser.name); actionBar.setSubtitle(DateFormat.format(getString(R.string.date_year_month_day), mDisplayedDate)); } // ? mDailyScheduleList.clear(); for (ScheduleData d : mScheduleDataList) { if (d.date.equals(mDisplayedDate)) { // //TextView tv_date = (TextView) findViewById(R.id.tv_schedule_date); //tv_date.setText(DateFormat.format(getString(R.string.date_month_day_week), d.date)); // ???? if (!d.scheduleList.isEmpty()) { mDailyScheduleList.addAll(d.scheduleList); } } } mDailyScheduleaListAdapter.notifyDataSetChanged(); }
From source file:org.appcelerator.titanium.util.TiUIHelper.java
public static void styleText(TextView tv, String fontFamily, String fontSize, String fontWeight, String fontStyle) {/*w w w. j av a 2 s.c o m*/ Typeface tf = tv.getTypeface(); tf = toTypeface(tv.getContext(), fontFamily); tv.setTypeface(tf, toTypefaceStyle(fontWeight, fontStyle)); tv.setTextSize(getSizeUnits(fontSize), getSize(fontSize)); }
From source file:org.uguess.android.sysinfo.NetStateManager.java
void setFont(TextView txt, int type) { if (txt.getTypeface() == null || txt.getTypeface().getStyle() != type) { txt.setTypeface(Typeface.DEFAULT, type); }//from ww w .j ava2 s . c o m }
From source file:com.mifos.mifosxdroid.online.generatecollectionsheet.GenerateCollectionSheetFragment.java
private void inflateProductiveCollectionTable(CollectionSheetResponse collectionSheetResponse) { //Clear old views in case they are present. if (tableProductive.getChildCount() > 0) { tableProductive.removeAllViews(); }// w ww.j av a2 s .c om if (tableAdditional.getVisibility() == View.VISIBLE) { tableAdditional.removeAllViews(); tableAdditional.setVisibility(View.GONE); } //A List to be used to inflate Attendance Spinners ArrayList<String> attendanceTypes = new ArrayList<>(); attendanceTypeOptions.clear(); attendanceTypeOptions = presenter.filterAttendanceTypes(collectionSheetResponse.getAttendanceTypeOptions(), attendanceTypes); //Add the heading Row TableRow headingRow = new TableRow(getContext()); TableRow.LayoutParams headingRowParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); headingRowParams.gravity = Gravity.CENTER; headingRowParams.setMargins(0, 0, 0, 10); headingRow.setLayoutParams(headingRowParams); TextView tvGroupName = new TextView(getContext()); tvGroupName.setText(collectionSheetResponse.getGroups().get(0).getGroupName()); tvGroupName.setTypeface(tvGroupName.getTypeface(), Typeface.BOLD); tvGroupName.setGravity(Gravity.CENTER); headingRow.addView(tvGroupName); for (LoanProducts loanProduct : collectionSheetResponse.getLoanProducts()) { TextView tvProduct = new TextView(getContext()); tvProduct.setText(getString(R.string.collection_heading_charges, loanProduct.getName())); tvProduct.setTypeface(tvProduct.getTypeface(), Typeface.BOLD); tvProduct.setGravity(Gravity.CENTER); headingRow.addView(tvProduct); } TextView tvAttendance = new TextView(getContext()); tvAttendance.setText(getString(R.string.attendance)); tvAttendance.setGravity(Gravity.CENTER); tvAttendance.setTypeface(tvAttendance.getTypeface(), Typeface.BOLD); headingRow.addView(tvAttendance); tableProductive.addView(headingRow); for (ClientCollectionSheet clientCollectionSheet : collectionSheetResponse.getGroups().get(0) .getClients()) { //Insert rows TableRow row = new TableRow(getContext()); TableRow.LayoutParams rowParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); rowParams.gravity = Gravity.CENTER; rowParams.setMargins(0, 0, 0, 10); row.setLayoutParams(rowParams); //Column 1: Client Name and Id TextView tvClientName = new TextView(getContext()); tvClientName.setText( concatIdWithName(clientCollectionSheet.getClientName(), clientCollectionSheet.getClientId())); row.addView(tvClientName); //Subsequent columns: The Loan products for (LoanProducts loanProduct : collectionSheetResponse.getLoanProducts()) { //Since there may be several items in this column, create a container. LinearLayout productContainer = new LinearLayout(getContext()); productContainer.setOrientation(LinearLayout.HORIZONTAL); //Iterate through all the loans in of this type and add in the container for (LoanCollectionSheet loanCollectionSheet : clientCollectionSheet.getLoans()) { if (loanProduct.getName().equals(loanCollectionSheet.getProductShortName())) { //This loan should be shown in this column. So, add it in the container. EditText editText = new EditText(getContext()); editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); editText.setText(String.format(Locale.getDefault(), "%f", 0.0)); //Set the loan id as the Tag of the EditText which //will later be used as the identifier for this. editText.setTag(TYPE_LOAN + ":" + loanCollectionSheet.getLoanId()); productContainer.addView(editText); } } row.addView(productContainer); } Spinner spAttendance = new Spinner(getContext()); setSpinner(spAttendance, attendanceTypes); row.addView(spAttendance); tableProductive.addView(row); } if (btnSubmitProductive.getVisibility() != View.VISIBLE) { //Show the button the first time sheet is loaded. btnSubmitProductive.setVisibility(View.VISIBLE); btnSubmitProductive.setOnClickListener(this); } //If this block has been executed, that the CollectionSheet //which is already shown on screen is for center - Productive. btnSubmitProductive.setTag(TAG_TYPE_PRODUCTIVE); }
From source file:com.mifos.mifosxdroid.online.generatecollectionsheet.GenerateCollectionSheetFragment.java
private void inflateCollectionTable(CollectionSheetResponse collectionSheetResponse) { //Clear old views in case they are present. if (tableProductive.getChildCount() > 0) { tableProductive.removeAllViews(); }//from w w w.j a v a 2 s . c o m //A List to be used to inflate Attendance Spinners ArrayList<String> attendanceTypes = new ArrayList<>(); attendanceTypeOptions.clear(); attendanceTypeOptions = presenter.filterAttendanceTypes(collectionSheetResponse.getAttendanceTypeOptions(), attendanceTypes); additionalPaymentTypeMap.clear(); additionalPaymentTypeMap = presenter.filterPaymentTypes(collectionSheetResponse.getPaymentTypeOptions(), paymentTypes); //Add the heading Row TableRow headingRow = new TableRow(getContext()); TableRow.LayoutParams headingRowParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); headingRowParams.gravity = Gravity.CENTER; headingRowParams.setMargins(0, 0, 0, 10); headingRow.setLayoutParams(headingRowParams); TextView tvGroupName = new TextView(getContext()); tvGroupName.setText(collectionSheetResponse.getGroups().get(0).getGroupName()); tvGroupName.setTypeface(tvGroupName.getTypeface(), Typeface.BOLD); tvGroupName.setGravity(Gravity.CENTER); headingRow.addView(tvGroupName); for (LoanProducts loanProduct : collectionSheetResponse.getLoanProducts()) { TextView tvProduct = new TextView(getContext()); tvProduct.setText(getString(R.string.collection_loan_product, loanProduct.getName())); tvProduct.setTypeface(tvProduct.getTypeface(), Typeface.BOLD); tvProduct.setGravity(Gravity.CENTER); headingRow.addView(tvProduct); } for (SavingsProduct savingsProduct : collectionSheetResponse.getSavingsProducts()) { TextView tvSavingProduct = new TextView(getContext()); tvSavingProduct.setText(getString(R.string.collection_saving_product, savingsProduct.getName())); tvSavingProduct.setTypeface(tvSavingProduct.getTypeface(), Typeface.BOLD); tvSavingProduct.setGravity(Gravity.CENTER); headingRow.addView(tvSavingProduct); } TextView tvAttendance = new TextView(getContext()); tvAttendance.setText(getString(R.string.attendance)); tvAttendance.setGravity(Gravity.CENTER); tvAttendance.setTypeface(tvAttendance.getTypeface(), Typeface.BOLD); headingRow.addView(tvAttendance); tableProductive.addView(headingRow); for (ClientCollectionSheet clientCollectionSheet : collectionSheetResponse.getGroups().get(0) .getClients()) { //Insert rows TableRow row = new TableRow(getContext()); TableRow.LayoutParams rowParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); rowParams.gravity = Gravity.CENTER; rowParams.setMargins(0, 0, 0, 10); row.setLayoutParams(rowParams); //Column 1: Client Name and Id TextView tvClientName = new TextView(getContext()); tvClientName.setText( concatIdWithName(clientCollectionSheet.getClientName(), clientCollectionSheet.getClientId())); row.addView(tvClientName); //Subsequent columns: The Loan products for (LoanProducts loanProduct : collectionSheetResponse.getLoanProducts()) { //Since there may be several items in this column, create a container. LinearLayout productContainer = new LinearLayout(getContext()); productContainer.setOrientation(LinearLayout.HORIZONTAL); //Iterate through all the loans in of this type and add in the container for (LoanCollectionSheet loan : clientCollectionSheet.getLoans()) { if (loanProduct.getName().equals(loan.getProductShortName())) { //This loan should be shown in this column. So, add it in the container. EditText editText = new EditText(getContext()); editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); editText.setText(String.format(Locale.getDefault(), "%f", 0.0)); //Set the loan id as the Tag of the EditText // in format 'TYPE:ID' which //will later be used as the identifier for this. editText.setTag(TYPE_LOAN + ":" + loan.getLoanId()); productContainer.addView(editText); } } row.addView(productContainer); } //After Loans, show Savings columns for (SavingsProduct product : collectionSheetResponse.getSavingsProducts()) { //Since there may be several Savings items in this column, create a container. LinearLayout productContainer = new LinearLayout(getContext()); productContainer.setOrientation(LinearLayout.HORIZONTAL); //Iterate through all the Savings in of this type and add in the container for (SavingsCollectionSheet saving : clientCollectionSheet.getSavings()) { if (saving.getProductId() == product.getId()) { //Add the saving in the container EditText editText = new EditText(getContext()); editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); editText.setText(String.format(Locale.getDefault(), "%f", 0.0)); //Set the Saving id as the Tag of the EditText // in 'TYPE:ID' format which //will later be used as the identifier for this. editText.setTag(TYPE_SAVING + ":" + saving.getSavingsId()); productContainer.addView(editText); } } row.addView(productContainer); } Spinner spAttendance = new Spinner(getContext()); //Set the clientId as its tag which will be used as identifier later. spAttendance.setTag(clientCollectionSheet.getClientId()); setSpinner(spAttendance, attendanceTypes); row.addView(spAttendance); tableProductive.addView(row); } if (btnSubmitProductive.getVisibility() != View.VISIBLE) { //Show the button the first time sheet is loaded. btnSubmitProductive.setVisibility(View.VISIBLE); btnSubmitProductive.setOnClickListener(this); } //If this block has been executed, that means the CollectionSheet //which is already shown is for groups. btnSubmitProductive.setTag(TAG_TYPE_COLLECTION); if (tableAdditional.getVisibility() != View.VISIBLE) { tableAdditional.setVisibility(View.VISIBLE); } //Show Additional Views TableRow rowPayment = new TableRow(getContext()); TextView tvLabelPayment = new TextView(getContext()); tvLabelPayment.setText(getString(R.string.payment_type)); rowPayment.addView(tvLabelPayment); Spinner spPayment = new Spinner(getContext()); setSpinner(spPayment, paymentTypes); rowPayment.addView(spPayment); tableAdditional.addView(rowPayment); TableRow rowAccount = new TableRow(getContext()); TextView tvLabelAccount = new TextView(getContext()); tvLabelAccount.setText(getString(R.string.account_number)); rowAccount.addView(tvLabelAccount); EditText etPayment = new EditText(getContext()); rowAccount.addView(etPayment); tableAdditional.addView(rowAccount); TableRow rowCheck = new TableRow(getContext()); TextView tvLabelCheck = new TextView(getContext()); tvLabelCheck.setText(getString(R.string.cheque_number)); rowCheck.addView(tvLabelCheck); EditText etCheck = new EditText(getContext()); rowCheck.addView(etCheck); tableAdditional.addView(rowCheck); TableRow rowRouting = new TableRow(getContext()); TextView tvLabelRouting = new TextView(getContext()); tvLabelRouting.setText(getString(R.string.routing_code)); rowRouting.addView(tvLabelRouting); EditText etRouting = new EditText(getContext()); rowRouting.addView(etRouting); tableAdditional.addView(rowRouting); TableRow rowReceipt = new TableRow(getContext()); TextView tvLabelReceipt = new TextView(getContext()); tvLabelReceipt.setText(getString(R.string.receipt_number)); rowReceipt.addView(tvLabelReceipt); EditText etReceipt = new EditText(getContext()); rowReceipt.addView(etReceipt); tableAdditional.addView(rowReceipt); TableRow rowBank = new TableRow(getContext()); TextView tvLabelBank = new TextView(getContext()); tvLabelBank.setText(getString(R.string.bank_number)); rowBank.addView(tvLabelBank); EditText etBank = new EditText(getContext()); rowBank.addView(etBank); tableAdditional.addView(rowBank); }