List of usage examples for android.widget TextView TextView
public TextView(Context context)
From source file:com.android.contacts.common.list.ContactListItemView.java
/** * Returns the text view for the data text, creating it if necessary. *///w ww. j a va 2 s.c o m public TextView getDataView() { if (mDataView == null) { mDataView = new TextView(getContext()); mDataView.setSingleLine(true); mDataView.setEllipsize(getTextEllipsis()); mDataView.setTextAppearance(getContext(), R.style.TextAppearanceSmall); mDataView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); mDataView.setActivated(isActivated()); mDataView.setId(R.id.cliv_data_view); if (CompatUtils.isLollipopCompatible()) { mDataView.setElegantTextHeight(false); } addView(mDataView); } return mDataView; }
From source file:apps.junkuvo.alertapptowalksafely.MainActivity.java
private Toast createToastShort(String text) { Toast toast = new Toast(this); TextView tv = new TextView(this); tv.setText(text);/*from www . j ava 2 s . c o m*/ tv.setTextColor(ContextCompat.getColor(this, R.color.colorAccent)); tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, TOAST_TEXT_SIZE); // int pixel = (int)mWindowDensity * 56; int toastMargin = getResources().getDimensionPixelSize(R.dimen.toast_margin_top_bottom); tv.setPadding(0, toastMargin, 0, toastMargin); toast.setView(tv); toast.setGravity(mToastPosition, 0, 0); toast.setDuration(Toast.LENGTH_SHORT); return toast; }
From source file:com.android.contacts.common.list.ContactListItemView.java
/** * Returns the text view for the search snippet, creating it if necessary. *///from w ww .j av a 2 s.com public TextView getSnippetView() { if (mSnippetView == null) { mSnippetView = new TextView(getContext()); mSnippetView.setSingleLine(true); mSnippetView.setEllipsize(getTextEllipsis()); mSnippetView.setTextAppearance(getContext(), android.R.style.TextAppearance_Small); mSnippetView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); mSnippetView.setActivated(isActivated()); addView(mSnippetView); } return mSnippetView; }
From source file:com.nttec.everychan.ui.gallery.GalleryActivity.java
private void setOnClickView(GalleryItemViewTag tag, String message, View.OnClickListener handler) { tag.thumbnailView.setVisibility(View.VISIBLE); tag.loadingView.setVisibility(View.GONE); TextView v = new TextView(GalleryActivity.this); v.setGravity(Gravity.CENTER);/*from ww w . ja va 2 s . c o m*/ v.setText(getSpannedText(message)); tag.layout.setVisibility(View.VISIBLE); tag.layout.addView(v); v.setOnClickListener(handler); }
From source file:com.android.contacts.common.list.ContactListItemView.java
/** * Returns the text view for the status, creating it if necessary. *///w ww . j a va2 s . c o m public TextView getStatusView() { if (mStatusView == null) { mStatusView = new TextView(getContext()); mStatusView.setSingleLine(true); mStatusView.setEllipsize(getTextEllipsis()); mStatusView.setTextAppearance(getContext(), android.R.style.TextAppearance_Small); mStatusView.setTextColor(mSecondaryTextColor); mStatusView.setActivated(isActivated()); mStatusView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); addView(mStatusView); } return mStatusView; }
From source file:com.sdspikes.fireworks.FireworksActivity.java
private TextView makeNewCardTextView(int width, GameState.Card card) { width = Math.min(width, MAX_CARD_WIDTH); width = Math.max(width, MIN_CARD_WIDTH); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(width, ViewGroup.LayoutParams.WRAP_CONTENT); TextView textView = new TextView(this); textView.setLayoutParams(params);//ww w.j a v a 2s .co m textView.setGravity(Gravity.CENTER); textView.setText(String.valueOf(card.rank)); textView.setBackgroundResource(HandFragment.cardColorToBGColor.get(card.color)); textView.setTextColor(getResources().getColor(HandFragment.cardColorToTextColor(card.color))); return textView; }
From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java
public static AlertDialog getaddtextdialog(String title, final int itemnumber, Context ctx) { AlertDialog.Builder getaddtext = new AlertDialog.Builder(ctx); final LinearLayout linearlayout = new LinearLayout(ctx); linearlayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); linearlayout.setOrientation(LinearLayout.VERTICAL); final EditText nameet = new EditText(ctx); nameet.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); final TextView fontname = new TextView(ctx); fontname.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); final TextView colorname = new TextView(ctx); colorname.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); final Spinner fontsizespinner = new Spinner(ctx); fontsizespinner.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); final Spinner colorspinner = new Spinner(ctx); fontsizespinner.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); List<String> fontsizelist = new ArrayList<String>(); for (int t = 1; t < 200; t++) { fontsizelist.add(u.s(t));/*from w w w . j ava2 s .c o m*/ } ArrayAdapter<String> fontsizearrayadapter = new ArrayAdapter<String>(ctx, R.layout.spinnertextview, fontsizelist); fontsizearrayadapter.setDropDownViewResource(R.layout.spinnertextview); List<String> colorlist = new ArrayList<String>(); { colorlist.add("RED"); colorlist.add("BLACK"); colorlist.add("BLUE"); colorlist.add("GREEN"); colorlist.add("WHITE"); colorlist.add("GRAY"); } ArrayAdapter<String> colorlistarrayadapter = new ArrayAdapter<String>(ctx, R.layout.spinnertextview, colorlist); fontsizearrayadapter.setDropDownViewResource(R.layout.spinnertextview); colorspinner.setAdapter(colorlistarrayadapter); fontsizespinner.setAdapter(fontsizearrayadapter); fontsizespinner.setSelection(getIndexofSpinner(fontsizespinner, "25")); fontname.setText("Select Font Size"); fontname.setTextSize(20f); colorname.setText("Select Color"); colorname.setTextSize(20f); linearlayout.addView(nameet); linearlayout.addView(fontname); linearlayout.addView(fontsizespinner); linearlayout.addView(colorname); linearlayout.addView(colorspinner); if (!(itemnumber == view.i)) { nameet.setText(view.ITEMstring[itemnumber]); fontsizespinner.setSelection(getIndexofSpinner(fontsizespinner, u.s(view.ITEMfontsize[itemnumber]))); colorspinner.setSelection(getIndexofSpinner(colorspinner, u.s(view.ITEMfontcolor[itemnumber]))); } getaddtext.setView(linearlayout); getaddtext.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); getaddtext.setTitle(title); getaddtext.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub String string = nameet.getText().toString(); float fontsize = fontsizespinner.getSelectedItemPosition() + 1; //ITEMelcnumber[itemselectednumber]=u.i(string); int colpos = colorspinner.getSelectedItemPosition(); int[] col = new int[] { Color.RED, Color.BLACK, Color.BLUE, Color.GREEN, Color.WHITE, Color.GRAY }; int color = col[colpos]; Log.d("addtext", u.s((int) fontsize) + colpos + color); view.ITEMstring[itemnumber] = string; view.ITEMfontsize[itemnumber] = (int) fontsize; view.ITEMfontcolor[itemnumber] = color; view.itemname = string; view.fontsize = (int) fontsize; view.color = color; view.invalidate(); dialog.dismiss(); FloorPlanActivity.writeonedbitem(itemnumber); } }); return getaddtext.create(); }
From source file:org.smilec.smile.student.CourseList.java
private void createScoreTable(Vector<Integer> _myscore, String username) { int num_right = countrightquestion(_myscore); int total_question = LAST_SCENE_NUM; TableLayout tl = (TableLayout) findViewById(R.id.tableLayoutSeeR); TextView text1 = (TextView) findViewById(R.id.Header01); text1.setText(getString(R.string.name) + ": " + username); TextView text2 = (TextView) findViewById(R.id.Header11); text2.setText(getString(R.string.t_score) + ":" + num_right + "/" + total_question); for (int i = 0; i < _myscore.size(); i++) { TableRow tr = new TableRow(getApplicationContext()); tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); int number = 0; number = i + 1;/* ww w.j a va2 s.co m*/ int score = _myscore.get(i); Button b = new Button(getApplicationContext()); b.setText("(" + number + ")"); b.setTextSize(resultSize1); // b.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); params.setMargins(returnPixels(30.0f), 0, returnPixels(30.0f), 0); b.setLayoutParams(params); b.setOnClickListener(new MyButtonListener(number)); /* Add Button to row. */ tr.addView(b); TextView text = new TextView(getApplicationContext()); if (score == 1) { // right text.setText("0"); } else { // wrong text.setText("X"); } text.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); text.setTextColor(Color.BLACK); text.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL); text.setTextSize(resultSize2); tr.addView(text); //tr.setBackgroundResource(R.drawable.sf_gradient_03); tl.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT)); } return; }
From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java
public void showchecksdialog() { Boolean passedchecks = false; String PositiveButtonString;/* w ww. j a v a 2 s.com*/ String DisplayChecksOrPassedString; String ListChecksString = dochecks(); String Title; if (ListChecksString.trim().length() == 0) { passedchecks = true; } if (passedchecks) { DisplayChecksOrPassedString = "Are you sure your finished editing floorplans?"; Title = "Exit"; PositiveButtonString = "OK"; } else { DisplayChecksOrPassedString = "You have outstanding issues with this floorplan, please correct these issues before exiting."; Title = "Outstanding Issues!"; PositiveButtonString = "IGNORE & EXIT"; } TextView showfailedcheckstv; showfailedcheckstv = new TextView(this); showfailedcheckstv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); showfailedcheckstv.setText(ListChecksString); showfailedcheckstv.setPadding(5, 5, 5, 5); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(Title).setMessage(DisplayChecksOrPassedString).setView(showfailedcheckstv) .setCancelable(false).setIcon(R.drawable.ic_launcher) .setPositiveButton(PositiveButtonString, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub balmvalues(); new SaveTask(progressDialog).execute(); try { sethourglassicons(); } catch (Throwable e) { } finish(); System.gc(); dialog.dismiss(); finish(); } }).setNegativeButton("CANCEL", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).setCancelable(true); getscaledialog = builder.create(); getscaledialog.show(); }