List of usage examples for android.widget TextView TextView
public TextView(Context context)
From source file:com.df.app.procedures.CarRecogniseLayout.java
/** * VIN??/*from w w w. j ava2 s. c om*/ */ private void checkVinAndGetCarSettings() { InputMethodManager imm = (InputMethodManager) rootView.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(findViewById(R.id.vin_edit).getWindowToken(), 0); final String vinString = getEditViewText(rootView, R.id.vin_edit); // ? if (vinString.equals("")) { Toast.makeText(rootView.getContext(), "VIN?", Toast.LENGTH_SHORT).show(); findViewById(R.id.vin_edit).requestFocus(); return; } // VIN? if (!isVin(vinString)) { View view1 = ((Activity) getContext()).getLayoutInflater().inflate(R.layout.popup_layout, null); TableLayout contentArea = (TableLayout) view1.findViewById(R.id.contentArea); TextView content = new TextView(view1.getContext()); content.setText("VIN?: " + vinString + "\n" + "VIN?????\n"); content.setTextSize(20f); contentArea.addView(content); setTextView(view1, R.id.title, getResources().getString(R.string.alert)); AlertDialog dialog = new AlertDialog.Builder(rootView.getContext()).setView(view1) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { setEditViewText(rootView, R.id.brand_edit, ""); findViewById(R.id.brand_select_button).setEnabled(false); // ???VIN getCarSettingsFromServer(); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { findViewById(R.id.vin_edit).requestFocus(); } }).create(); dialog.show(); return; } setEditViewText(rootView, R.id.brand_edit, ""); findViewById(R.id.brand_select_button).setEnabled(false); // ???VIN getCarSettingsFromServer(); }
From source file:com.appfirst.activities.details.AFServerDetail.java
/** * Draw a ScrollView to display the Disk usage for each disk. * /*from ww w . j a v a 2 s . c om*/ * @return a ScrollView containing a list of AFBarView and AFPieView. */ private View createDiskListDialog() { // use the scroll view to scale ScrollView container = createOuterContainer(); LinearLayout innerContainer = createInnerContainer(); List<BasicNameValuePair> items = data.getDisk_percent_part(); for (int i = 0; i < items.size(); i++) { BasicNameValuePair item = items.get(i); Double value = Double.parseDouble(item.getValue()); String name = item.getName(); LinearLayout row = createTableRow(LinearLayout.HORIZONTAL); AFPieView pieView = createPieView(value); row.addView(pieView); TextView text = new TextView(this); text.setPadding(10, 0, 0, 0); text.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); text.setText(String.format("%s - %.1f %s used", name, value, "%")); row.addView(text); innerContainer.addView(row); } container.addView(innerContainer); innerContainer.invalidate(); container.invalidate(); return container; }
From source file:android.support.designox.widget.TextInputLayout.java
/** * Whether the error functionality is enabled or not in this layout. Enabling this * functionality before setting an error message via {@link #setError(CharSequence)}, will mean * that this layout will not change size when an error is displayed. * * @attr ref android.support.designox.R.styleable#TextInputLayout_errorEnabled *//*from w w w . j av a 2 s .com*/ public void setErrorEnabled(boolean enabled) { if (mErrorEnabled != enabled) { if (mErrorView != null) { ViewCompat.animate(mErrorView).cancel(); } if (enabled) { mErrorView = new TextView(getContext()); try { mErrorView.setTextAppearance(getContext(), mErrorTextAppearance); } catch (Exception e) { // Probably caused by our theme not extending from Theme.Design*. Instead // we manually set something appropriate mErrorView.setTextAppearance(getContext(), R.style.TextAppearance_AppCompat_Caption); mErrorView.setTextColor( ContextCompat.getColor(getContext(), R.color.design_textinput_error_color_light)); } mErrorView.setVisibility(INVISIBLE); ViewCompat.setAccessibilityLiveRegion(mErrorView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE); addIndicator(mErrorView, 0); } else { mErrorShown = false; updateEditTextBackground(); removeIndicator(mErrorView); mErrorView = null; } mErrorEnabled = enabled; } }
From source file:com.seatgeek.placesautocompletedemo.MainFragment.java
private void setUiPageViewController(View parent) { dotsLayout = (LinearLayout) parent.findViewById(R.id.viewPagerCountDots); dotsCount = 5;/*from w w w .j av a2 s .c o m*/ dots = new TextView[dotsCount]; for (int i = 0; i < dotsCount; i++) { dots[i] = new TextView(getActivity()); dots[i].setText(Html.fromHtml("•")); dots[i].setTextSize(30); dots[i].setTextColor(getResources().getColor(android.R.color.darker_gray)); dotsLayout.addView(dots[i]); } dots[0].setTextColor(Color.GREEN); }
From source file:ca.mudar.parkcatcher.ui.fragments.DetailsFragment.java
private TextView getPanel(String desc, LayoutParams params, int textColor) { desc = desc.trim().toUpperCase();//from w w w.j ava 2 s .c o m final TextView panelUi = new TextView(getSherlockActivity()); panelUi.setGravity(Gravity.CENTER_HORIZONTAL); panelUi.setLayoutParams(params); panelUi.setTextColor(textColor); String prefix = (String) desc.subSequence(0, 2); prefix = prefix.trim(); try { // Start with a figure: authorized duration Integer.valueOf(prefix.trim()); panelUi.setBackgroundResource(R.drawable.bg_panel_parking); } catch (NumberFormatException e) { if (desc.subSequence(0, 1).equals("P")) { // Starts with "P " (trimmed): authorized panelUi.setBackgroundResource(R.drawable.bg_panel_parking); desc = desc.substring(1); } else if (desc.subSequence(0, 2).equals("\\A")) { panelUi.setBackgroundResource(R.drawable.bg_panel_no_stopping); desc = desc.substring(2); } else if (desc.subSequence(0, 2).equals("\\P")) { panelUi.setBackgroundResource(R.drawable.bg_panel_no_parking); desc = desc.substring(2); } else { panelUi.setBackgroundResource(R.drawable.bg_panel_no_parking); } } panelUi.setText(desc.trim()); return panelUi; }
From source file:terse.a1.TerseActivity.java
public void viewPath(String path, String queryStr, Bundle extras, Bundle savedInstanceState) { // Stop any running WorkThread before we continue. viewPath1prepare(path, queryStr);/* ww w . j a v a 2 s . co m*/ viewPath2parseQuery(queryStr, extras); final LayoutParams widgetParams = new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, 1.0f); TextView splash = new TextView(TerseActivity.this); splash.setText("Launching\n\n" + taPath + "\n\n" + Static.hashMapToMultiLineString(taQuery)); splash.setTextAppearance(this, R.style.teletype); splash.setBackgroundColor(Color.BLACK); splash.setTextColor(Color.DKGRAY); splash.setTextSize(24); Runnable bg = new Runnable() { @Override public void run() { try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } }; Runnable fg = new Runnable() { @Override public void run() { viewPath9display(taPath, widgetParams); } }; setContentViewThenBgThenFg("viewPath8", splash, bg, fg); }
From source file:de.da_sense.moses.client.FormFragment.java
/** * Displays a single choice question to the user. * @param question the question to be displayed * @param linearLayoutInsideAScrollView the view to add the question to * @param ordinal the ordinal number of the question i.e. 1, 2, 3, 4 or 5 *///w ww .j a v a 2 s. com private void makeSingleChoice(final Question question, LinearLayout linearLayoutInsideAScrollView, int ordinal) { LinearLayout questionContainer = generateQuestionContainer(linearLayoutInsideAScrollView); String questionText = question.getTitle(); List<PossibleAnswer> possibleAnswers = question.getPossibleAnswers(); Collections.sort(possibleAnswers); TextView questionView = new TextView(getActivity()); questionView.setText(ordinal + ". " + questionText); if (question.isMandatory()) questionView.setTextAppearance(getActivity(), R.style.QuestionTextStyleMandatory); else questionView.setTextAppearance(getActivity(), R.style.QuestionTextStyle); questionContainer.addView(questionView); mQuestionTitleMappings.put(question, questionView); final RadioButton[] rb = new RadioButton[possibleAnswers.size()]; RadioGroup rg = new RadioGroup(getActivity()); // create the RadioGroup rg.setOrientation(RadioGroup.VERTICAL);// or RadioGroup.VERTICAL String madeAnswer = question.getAnswer(); int madeAnswerInt = -1; if (!madeAnswer.equals(Question.ANSWER_UNANSWERED)) madeAnswerInt = Integer.parseInt(madeAnswer); for (int i = 0; i < rb.length; i++) { rb[i] = new RadioButton(getActivity()); if (i % 2 == 0) rb[i].setBackgroundColor(getActivity().getResources().getColor(R.color.light_gray)); rg.addView(rb[i]); // the RadioButtons are added to the radioGroup // instead of the layout PossibleAnswer possibleAnswer = possibleAnswers.get(i); rb[i].setText(possibleAnswer.getTitle()); final int possibleAnswerId = possibleAnswer.getId(); if (madeAnswerInt == possibleAnswerId) rb[i].setChecked(true); rb[i].setTextAppearance(getActivity(), R.style.PossibleAnswerTextStyle); LayoutParams rowParam = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); rb[i].setLayoutParams(rowParam); // click handling rb[i].setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { question.setAnswer(String.valueOf(possibleAnswerId)); } }); if (mBelongsTo == WelcomeActivityPagerAdapter.TAB_HISTORY) rb[i].setEnabled(false); rb[i].setVisibility(View.VISIBLE); } rg.setVisibility(View.VISIBLE); if (mBelongsTo == WelcomeActivityPagerAdapter.TAB_HISTORY) rg.setEnabled(false); Log.i(LOG_TAG, "last rg = " + rg); questionContainer.addView(rg); }
From source file:com.astuetz.PagerSlidingTabStripPlus.java
/** * Add new text view to the linear layout that contains the tab title* * @param position of the linear layout in the tabsContainer * @param text is the text of the subtitle *///w ww . ja v a 2s. c o m public void addSubtitleAtTab(int position, String text) { LinearLayout tab = getSingleTabLayoutAtPosition(position); tab.setWeightSum(tab.getChildCount() + 1); if (tab.getChildCount() == 1) { tab.getChildAt(0).setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0, 1)); } ((TextView) tab.getChildAt(0)).setGravity(Gravity.CENTER_HORIZONTAL); TextView newSubTab = new TextView(getContext()); newSubTab.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0, 1)); newSubTab.setText(text); newSubTab.setGravity(Gravity.CENTER_HORIZONTAL); tab.addView(newSubTab); updateTabStyles(); }
From source file:com.bridgeconn.autographago.ui.activities.SettingsActivity.java
public void getMetaData(final String language, final String version) { mProgressBar.setVisibility(View.VISIBLE); mTvDownload.setOnClickListener(null); final DownloadUtil downloadUtil = new DownloadUtil(); downloadUtil.downloadJson(language + "/" + version + "/" + Constants.META_DATA_FILE_NAME, new DownloadUtil.JsonDownloadCallback() { @Override//from ww w . jav a2 s .c o m public void onSuccess(final ResponseModel model) { mProgressBar.setVisibility(View.GONE); mTvDownload.setOnClickListener(SettingsActivity.this); if (model.getMetaData() != null) { languageName = model.getMetaData().getLanguageName(); languageCode = model.getMetaData().getLanguageCode(); versionCode = model.getMetaData().getVersionCode(); versionName = model.getMetaData().getVersionName(); TextView tv = new TextView(SettingsActivity.this); tv.setText(model.getMetaData().getSource() + " :: " + model.getMetaData().getLanguageName() + " :: " + model.getMetaData().getLicense() + " :: " + model.getMetaData().getYear() + " :: " + model.getMetaData().getVersionName()); Button button = new Button(SettingsActivity.this); button.setText(getResources().getString(R.string.download) + " " + model.getMetaData().getLanguageName() + " " + model.getMetaData().getVersionCode() + " Bible"); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { downloadUrl = Constants.API_BASE_URL + language + "/" + version + "/" + Constants.USFM_ZIP_FILE_NAME; if (ContextCompat.checkSelfPermission(SettingsActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(SettingsActivity.this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, Constants.RequestCodes.PERMISSION_STORAGE); return; } startDownload(downloadUrl); } }); // mInflateLayout.addView(tv); mInflateLayout.addView(button); } else { Toast.makeText(SettingsActivity.this, getResources().getString(R.string.server_error), Toast.LENGTH_SHORT).show(); } } @Override public void onFailure() { mProgressBar.setVisibility(View.GONE); mTvDownload.setOnClickListener(SettingsActivity.this); Toast.makeText(SettingsActivity.this, getResources().getString(R.string.network_error), Toast.LENGTH_SHORT).show(); } }); }
From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityCreateOrEditRoute.java
/** initAddDestButton() * adds the Driving Through button/*from w w w. j a v a 2s . co m*/ */ protected void initAddDestButton() { //Adds/enables the FrameLayout AddDestFrameLayout = new FrameLayout(this); AddDestFrameLayout.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT, 80)); AddDestFrameLayout.setEnabled(true); //Fills the Image Icon ImageView destAddIcon = new ImageView(this); FrameLayout.LayoutParams lliDestIcon = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); lliDestIcon.setMargins(dipToPx(10), 0, 0, dipToPx(2)); destAddIcon.setLayoutParams(lliDestIcon); destAddIcon.setPadding(0, dipToPx(5), 0, 0); destAddIcon.setImageResource(R.drawable.google_marker_thumb_mini_through); //Adds the imageicon to the framelayout/enables it AddDestFrameLayout.addView(destAddIcon); //Fills/sets the text TextView destAddText = new TextView(this); FrameLayout.LayoutParams lliDest = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); lliDest.setMargins(0, dipToPx(5), 0, 0); destAddText.setLayoutParams(lliDest); destAddText.setPadding(dipToPx(40), dipToPx(6), 0, 0); destAddText.setTextSize(15); destAddText.setText(R.string.mapViewAcField); //Adds the text to the framelayout AddDestFrameLayout.addView(destAddText); //Adds the framelayout to the linearlayout (in the scrollview) sclLayout = (LinearLayout) findViewById(R.id.sclLayout); sclLayout.addView(AddDestFrameLayout, sclLayout.getChildCount()); final Button button = ((Button) findViewById(R.id.btnChooseRoute)); //Adds a clicklistener to the frameLayout AddDestFrameLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //Adds a new destination field initDestFrameLayout(); //Moves the button to the bottom setLayoutParams(); if (checkFields() == false) { button.setEnabled(false); button.setText("Show on map"); } else { mapView.getOverlays().clear(); createMap(); } } }); }