List of usage examples for android.widget TextView setText
@android.view.RemotableViewMethod public final void setText(@StringRes int resid)
From source file:com.wbs.itm.SelectedQuestionActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.all_ans);/*from w w w.j a va 2s . c o m*/ selquesList = new ArrayList<HashMap<String, String>>(); Intent newqestionintent = getIntent(); String newquestion = newqestionintent.getExtras().getString("TAG_QUESTION"); new LoadAllSelques().execute(); TextView text = (TextView) findViewById(R.id.selectedquestion); text.setText("Q. "); text.append(newquestion); ListView lv = getListView(); Button gohome = (Button) findViewById(R.id.gohome); gohome.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(getApplicationContext(), TalkyLaunchActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i); } }); Button ansbtn = (Button) findViewById(R.id.ansbtn); ansbtn.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { newqintent = getIntent(); newqid = newqintent.getExtras().getString("TAG_PID"); /*String newpid = ((TextView) findViewById(R.id.qid)).getText() .toString();*/ Intent mynewIntent = new Intent(SelectedQuestionActivity.this, NewAnswerActivity.class); mynewIntent.putExtra("TAG_newPID", newqid); SelectedQuestionActivity.this.startActivity(mynewIntent); } }); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // getting values from selected ListItem // Do nothing! //Later on implement selective Replies. } }); }
From source file:fi.iki.murgo.irssinotifier.InitialSettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.initialsettings); preferences = new Preferences(this); if (LicenseHelper.isPlusVersion(this)) { TextView tv = (TextView) findViewById(R.id.textViewWelcomeHelp); tv.setText(getString(R.string.welcome_thanks_for_support) + " " + tv.getText()); }/* ww w .ja va 2 s .c om*/ UserHelper fetcher = new UserHelper(); final Account[] accounts = fetcher.getAccounts(this); String[] accountNames = new String[accounts.length]; for (int i = 0; i < accounts.length; i++) { accountNames[i] = accounts[i].name; } ListView listView = (ListView) findViewById(R.id.accountsList); listView.setAdapter(new ArrayAdapter<String>(this, R.layout.accountlistitem, accountNames)); listView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Account account = accounts[arg2]; preferences.setAccountName(account.name); preferences.setNotificationsEnabled(true); whatNext(0); } }); if (LicenseHelper.bothEditionsInstalled(this)) { MessageBox.Show(this, null, getString(R.string.both_versions_installed), null); } }
From source file:de.geeksfactory.opacclient.frontend.AccountListAdapter.java
@SuppressWarnings("deprecation") @Override/*w w w .j a v a2s .c o m*/ public View getView(int position, View contentView, ViewGroup viewGroup) { View view; // position always 0-7 if (objects.get(position) == null) { LayoutInflater layoutInflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = layoutInflater.inflate(R.layout.listitem_account, viewGroup, false); return view; } Account item = objects.get(position); if (contentView == null) { LayoutInflater layoutInflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = layoutInflater.inflate(R.layout.listitem_account, viewGroup, false); } else { view = contentView; } if (((OpacClient) ((Activity) context).getApplication()).getAccount().getId() == item.getId() && highlight) { view.findViewById(R.id.rlItem).setBackgroundColor(context.getResources().getColor(R.color.accent_red)); } else { // should be replaced by setBackground which is not available before API level 16 view.findViewById(R.id.rlItem).setBackgroundDrawable(null); } Library lib; try { lib = ((OpacClient) ((Activity) context).getApplication()).getLibrary(item.getLibrary()); TextView tvCity = (TextView) view.findViewById(R.id.tvCity); if (lib.getTitle() != null && !lib.getTitle().equals("null")) { tvCity.setText(lib.getCity() + "\n" + lib.getTitle()); } else { tvCity.setText(lib.getCity()); } } catch (IOException | JSONException e) { e.printStackTrace(); } TextView tvName = (TextView) view.findViewById(R.id.tvName); if (item.getName() != null) { tvName.setText(item.getName()); } TextView tvLabel = (TextView) view.findViewById(R.id.tvLabel); if (item.getLabel() != null) { tvLabel.setText(item.getLabel()); } return view; }
From source file:fr.cph.chicago.core.adapter.PopupBusDetailsFavoritesAdapter.java
@Override public final View getView(final int position, final View convertView, final ViewGroup parent) { final LayoutInflater vi = (LayoutInflater) parent.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View rowView = vi.inflate(R.layout.popup_bus_cell_0, parent, false); final TextView textView = (TextView) rowView.findViewById(R.id.label); final String toDisplay = values.get(position).getStopName() + " (" + WordUtils.capitalize(values.get(position).getBound().toLowerCase()) + ")"; textView.setText(toDisplay); return rowView; }
From source file:gov.wa.wsdot.android.wsdot.ui.MountainPassItemCameraFragment.java
public void onLoadFinished(Loader<ArrayList<CameraItem>> loader, ArrayList<CameraItem> data) { mLoadingSpinner.setVisibility(View.GONE); if (!data.isEmpty()) { mAdapter.setData(data);//from w w w .ja v a2s. c om } else { TextView t = (TextView) mEmptyView; t.setText(R.string.no_connection); getListView().setEmptyView(mEmptyView); } }
From source file:mil.nga.giat.mage.help.OpensourceItemFragment.java
private void initView(Context context, AttributeSet attrs) { View view = inflate(getContext(), R.layout.fragment_opensource_item, null); if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.OpensourceItemFragment); CharSequence name = a.getText(R.styleable.OpensourceItemFragment_name); CharSequence copyright = a.getText(R.styleable.OpensourceItemFragment_copyright); CharSequence license = a.getText(R.styleable.OpensourceItemFragment_license); a.recycle();/* w w w . ja v a 2 s . c o m*/ TextView nameTextView = (TextView) view.findViewById(R.id.opensource_item_name); if (StringUtils.isBlank(name)) { nameTextView.setVisibility(View.GONE); } else { nameTextView.setText(name); } TextView copyrightTextView = (TextView) view.findViewById(R.id.opensource_item_copyright); if (StringUtils.isBlank(copyright)) { copyrightTextView.setVisibility(View.GONE); } else { copyrightTextView.setText(copyright); } TextView licenseTextView = (TextView) view.findViewById(R.id.opensource_item_license); if (StringUtils.isBlank(license)) { licenseTextView.setVisibility(View.GONE); } else { licenseTextView.setText(license); } } addView(view); }
From source file:net.eledge.android.europeana.gui.dialog.NameInputDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = getActivity().getLayoutInflater(); View view = inflater.inflate(R.layout.dialog_nameinput, null); TextView text = (TextView) view.findViewById(R.id.dialog_nameinput_textview); if (resText != -1) { text.setText(resText); } else {// w ww. j a v a 2 s. co m text.setVisibility(View.GONE); } mInput = (EditText) view.findViewById(R.id.dialog_nameinput_edittext); mInput.setHint(resInput); mInput.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { //ignore } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { //ignore } @Override public void afterTextChanged(Editable s) { mDialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(StringUtils.isNotBlank(s.toString())); } }); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(view); if (resTitle != -1) { builder.setTitle(resTitle); } builder.setPositiveButton(resPositiveButton, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { String input = mInput.getText().toString(); if (StringUtils.isNotBlank(input)) { mListener.positiveResponse(input); NameInputDialog.this.dismiss(); } } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { mListener.negativeResponse(); mDialog.dismiss(); } }); mDialog = builder.create(); mDialog.setCanceledOnTouchOutside(false); mDialog.setCancelable(false); return mDialog; }
From source file:com.manning.androidhacks.hack042.adapter.PoisAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { TextView tv; if (convertView == null) { convertView = createView();/*w w w. jav a2 s. c om*/ } Poi poi = getItem(position); tv = (TextView) convertView.findViewById(R.id.poi_row_title); tv.setText(poi.getName()); tv = (TextView) convertView.findViewById(R.id.poi_row_latitude); tv.setText("" + poi.getLatitude()); tv = (TextView) convertView.findViewById(R.id.poi_row_longitude); tv.setText("" + poi.getLongitude()); tv = (TextView) convertView.findViewById(R.id.poi_row_distance); tv.setText("" + poi.getDistance()); return convertView; }
From source file:com.rucker.weatherface.asynctask.GetWeatherInfoTask.java
protected void onPostExecute(HashMap<String, String> result) { TextView tv = (TextView) caller.findViewById(callerViewId); //FIXME: Use of constants below produces coupling between this task and the main activity. tv.setText("It looks like you are near " + result.get(MainActivity.KEY_LOCATION_NAME) + ".\n" + "The current temperature is " + result.get(MainActivity.KEY_TEMP) + "."); }
From source file:com.linkedin.android.eventsapp.ProfileActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_profile); Bundle extras = getIntent() != null ? getIntent().getExtras() : new Bundle(); final Person person = extras.getParcelable("person"); final Activity currentActivity = this; final ActionBar bar = getActionBar(); View viewActionBar = getLayoutInflater().inflate(R.layout.layout_action_bar, null); ImageView backView = (ImageView) viewActionBar.findViewById(R.id.actionbar_left); backView.setImageResource(R.drawable.arrow_left); backView.setVisibility(View.VISIBLE); backView.setClickable(true);/*w ww . j a va 2s.co m*/ backView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { currentActivity.finish(); } }); ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.MATCH_PARENT); bar.setCustomView(viewActionBar, params); bar.setDisplayShowCustomEnabled(true); bar.setDisplayShowTitleEnabled(false); bar.setIcon(new ColorDrawable(Color.TRANSPARENT)); bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#F15153"))); TextView attendeeNameView = (TextView) findViewById(R.id.attendeeName); attendeeNameView.setText(person.getFirstName() + " " + person.getLastName()); final ImageView attendeeImageView = (ImageView) findViewById(R.id.attendeeImage); final TextView attendeeHeadlineView = (TextView) findViewById(R.id.attendeeHeadline); final TextView attendeeLocationView = (TextView) findViewById(R.id.attendeeLocation); boolean isAccessTokenValid = LISessionManager.getInstance(currentActivity).getSession().isValid(); if (isAccessTokenValid) { String url = Constants.personByIdBaseUrl + person.getLinkedinId() + Constants.personProjection; APIHelper.getInstance(currentActivity).getRequest(currentActivity, url, new ApiListener() { @Override public void onApiSuccess(ApiResponse apiResponse) { try { JSONObject s = apiResponse.getResponseDataAsJson(); String headline = s.has("headline") ? s.getString("headline") : ""; String pictureUrl = s.has("pictureUrl") ? s.getString("pictureUrl") : null; JSONObject location = s.getJSONObject("location"); String locationName = location != null && location.has("name") ? location.getString("name") : ""; attendeeHeadlineView.setText(headline); attendeeLocationView.setText(locationName); if (pictureUrl != null) { new FetchImageTask(attendeeImageView).execute(pictureUrl); } else { attendeeImageView.setImageResource(R.drawable.ghost_person); } } catch (JSONException e) { } } @Override public void onApiError(LIApiError apiError) { } }); ViewStub viewOnLIStub = (ViewStub) findViewById(R.id.viewOnLIStub); View viewOnLI = viewOnLIStub.inflate(); Button viewOnLIButton = (Button) viewOnLI.findViewById(R.id.viewOnLinkedInButton); viewOnLIButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DeepLinkHelper.getInstance().openOtherProfile(currentActivity, person.getLinkedinId(), new DeepLinkListener() { @Override public void onDeepLinkSuccess() { } @Override public void onDeepLinkError(LIDeepLinkError error) { } }); } }); } else { attendeeImageView.setImageResource(R.drawable.ghost_person); } }