List of usage examples for android.widget TextView setText
@android.view.RemotableViewMethod public final void setText(@StringRes int resid)
From source file:id.zelory.tanipedia.activity.BacaActivity.java
private void generateBeritaLainnya() { beritaArrayList = Utils.getRandomBerita(this, tmp.getAlamat()); lainnya = (TextView) findViewById(R.id.lainnya); lainnya.setVisibility(View.GONE); berita1 = (CardView) findViewById(R.id.berita1); berita1.setVisibility(View.GONE); berita1.setOnClickListener(this); berita2 = (CardView) findViewById(R.id.berita2); berita2.setVisibility(View.GONE); berita2.setOnClickListener(this); berita3 = (CardView) findViewById(R.id.berita3); berita3.setVisibility(View.GONE); berita3.setOnClickListener(this); berita4 = (CardView) findViewById(R.id.berita4); berita4.setVisibility(View.GONE); berita4.setOnClickListener(this); berita5 = (CardView) findViewById(R.id.berita5); berita5.setVisibility(View.GONE); berita5.setOnClickListener(this); TextView judul = (TextView) findViewById(R.id.judul1); judul.setText(beritaArrayList.get(0).getJudul()); TextView tanggal = (TextView) findViewById(R.id.tanggal1); tanggal.setText(beritaArrayList.get(0).getTanggal()); ImageView gambar = (ImageView) findViewById(R.id.gambar1); Picasso.with(this).load(beritaArrayList.get(0).getGambar()).into(gambar); judul = (TextView) findViewById(R.id.judul2); judul.setText(beritaArrayList.get(1).getJudul()); tanggal = (TextView) findViewById(R.id.tanggal2); tanggal.setText(beritaArrayList.get(1).getTanggal()); gambar = (ImageView) findViewById(R.id.gambar2); Picasso.with(this).load(beritaArrayList.get(1).getGambar()).into(gambar); judul = (TextView) findViewById(R.id.judul3); judul.setText(beritaArrayList.get(2).getJudul()); tanggal = (TextView) findViewById(R.id.tanggal3); tanggal.setText(beritaArrayList.get(2).getTanggal()); gambar = (ImageView) findViewById(R.id.gambar3); Picasso.with(this).load(beritaArrayList.get(2).getGambar()).into(gambar); judul = (TextView) findViewById(R.id.judul4); judul.setText(beritaArrayList.get(3).getJudul()); tanggal = (TextView) findViewById(R.id.tanggal4); tanggal.setText(beritaArrayList.get(3).getTanggal()); gambar = (ImageView) findViewById(R.id.gambar4); Picasso.with(this).load(beritaArrayList.get(3).getGambar()).into(gambar); judul = (TextView) findViewById(R.id.judul5); judul.setText(beritaArrayList.get(4).getJudul()); tanggal = (TextView) findViewById(R.id.tanggal5); tanggal.setText(beritaArrayList.get(4).getTanggal()); gambar = (ImageView) findViewById(R.id.gambar5); Picasso.with(this).load(beritaArrayList.get(4).getGambar()).into(gambar); }
From source file:com.example.office.ui.mail.MailItemFragment.java
/** * Fills fragment content with email fields * * @param root Root view for current fragment *//*from ww w. j ava 2s . co m*/ private void displayMail(View root) { try { TextView subjectView = (TextView) root.findViewById(R.id.mail_fragment_subject); subjectView.setText(mail.getSubject()); StringBuilder recipients = new StringBuilder( getActivity().getString(R.string.me_and_somebody_text_stub)); if (mail.getRecipients() != null && mail.getRecipients().size() > 0) { for (Recipient r : mail.getRecipients()) { recipients.append(r.getName()); } } else { recipients.append("<unknown>"); } TextView participantsView = (TextView) root.findViewById(R.id.mail_fragment_participants); participantsView.setText(recipients.toString()); TextView dateView = (TextView) root.findViewById(R.id.mail_fragment_date); dateView.setText(""); WebView webview = (WebView) root.findViewById(R.id.mail_fragment_content); if (mail.getBody().getContentType() == BodyType.HTML) { webview.loadData(mail.getBody().getContent(), getActivity().getString(R.string.mime_type_text_html), "utf8"); } else { webview.loadData(mail.getBody().getContent(), getActivity().getString(R.string.mime_type_text_plain), "utf8"); } } catch (Exception e) { Logger.logApplicationException(e, getClass().getSimpleName() + ".displayMail(): Error."); } }
From source file:de.geeksfactory.opacclient.frontend.ResultsAdapter.java
@Override public View getView(int position, View contentView, ViewGroup viewGroup) { View view;/* ww w .j a v a 2 s. c o m*/ // position always 0-7 if (objects.get(position) == null) { LayoutInflater layoutInflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = layoutInflater.inflate(R.layout.listitem_searchresult, viewGroup, false); return view; } SearchResult item = objects.get(position); if (contentView == null) { LayoutInflater layoutInflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = layoutInflater.inflate(R.layout.listitem_searchresult, viewGroup, false); } else { view = contentView; } TextView tv = (TextView) view.findViewById(R.id.tvResult); tv.setText(Html.fromHtml(item.getInnerhtml())); ImageView ivType = (ImageView) view.findViewById(R.id.ivType); PreferenceDataSource pds = new PreferenceDataSource(getContext()); ConnectivityManager connMgr = (ConnectivityManager) getContext() .getSystemService(Context.CONNECTIVITY_SERVICE); if (item.getCoverBitmap() != null) { ivType.setImageBitmap(BitmapUtils.bitmapFromBytes(item.getCoverBitmap())); ivType.setVisibility(View.VISIBLE); ivType.setPadding(0, 0, 0, 0); } else if ((pds.isLoadCoversOnDataPreferenceSet() || !ConnectivityManagerCompat.isActiveNetworkMetered(connMgr)) && item.getCover() != null) { LoadCoverTask lct = new LoadCoverTask(ivType, item); lct.execute(); ivType.setImageResource(R.drawable.ic_loading); ivType.setVisibility(View.VISIBLE); ivType.setPadding(0, 0, 0, 0); } else if (item.getType() != null && item.getType() != MediaType.NONE) { ivType.setImageResource(getResourceByMediaType(item.getType())); ivType.setVisibility(View.VISIBLE); ivType.setPadding(padding8dp, padding8dp, padding8dp, padding8dp); } else { ivType.setVisibility(View.INVISIBLE); } ImageView ivStatus = (ImageView) view.findViewById(R.id.ivStatus); if (item.getStatus() != null) { ivStatus.setVisibility(View.VISIBLE); switch (item.getStatus()) { case GREEN: ivStatus.setImageResource(R.drawable.status_light_green_check); break; case RED: ivStatus.setImageResource(R.drawable.status_light_red_cross); break; case YELLOW: ivStatus.setImageResource(R.drawable.status_light_yellow_alert); break; case UNKNOWN: ivStatus.setVisibility(View.INVISIBLE); break; } } else { ivStatus.setVisibility(View.GONE); } return view; }
From source file:com.messagesight.mqtthelper.PayloadAdapter.java
@Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { String headerTitle = (String) getGroup(groupPosition); if (convertView == null) { LayoutInflater inflater = (LayoutInflater) this.ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.list_group, null); }//from www . j a v a2 s. c om TextView lblListHeader = (TextView) convertView.findViewById(R.id.lblListHeader); lblListHeader.setTypeface(null, Typeface.BOLD); String[] tempTitle = headerTitle.split(":"); headerTitle = tempTitle[0]; lblListHeader.setText(headerTitle); return convertView; }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.FeedRefObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();//from w ww . j ava2 s . co m byte[] raw = obj.getRaw(); TextView view = new TextView(context); view.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); String feedName = content.optString(FEED_ID); view.setText(feedName); view.setBackgroundColor(Feed.colorFor(feedName)); frame.addView(view); }
From source file:MainActivity.java
public void checkStatus(View view) { TextView textView = (TextView) findViewById(R.id.textView); if (isOnline()) { ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService( Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); textView.setText(networkInfo.getTypeName()); } else {//from ww w . ja va 2s . co m textView.setText("Offline"); } }
From source file:id.zelory.tanipedia.activity.KomoditasActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_komoditas); toolbar = (Toolbar) findViewById(R.id.anim_toolbar); setSupportActionBar(toolbar);//from w w w.j ava 2 s.c om getSupportActionBar().setDisplayHomeAsUpEnabled(true); CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbar.setTitle("Harga Komoditas"); animation = AnimationUtils.loadAnimation(this, R.anim.simple_grow); drawerLayout = (DrawerLayout) findViewById(R.id.nav_drawer); setUpNavDrawer(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.getMenu().getItem(3).setChecked(true); TextView nama = (TextView) navigationView.findViewById(R.id.nama); nama.setText(PrefUtils.ambilString(this, "nama")); TextView email = (TextView) navigationView.findViewById(R.id.email); email.setText(PrefUtils.ambilString(this, "email")); navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { menuItem.setChecked(true); drawerLayout.closeDrawers(); Intent intent; switch (menuItem.getItemId()) { case R.id.cuaca: intent = new Intent(KomoditasActivity.this, CuacaActivity.class); break; case R.id.berita: intent = new Intent(KomoditasActivity.this, BeritaActivity.class); break; case R.id.tanya: intent = new Intent(KomoditasActivity.this, TanyaActivity.class); break; case R.id.harga: return true; case R.id.logout: PrefUtils.simpanString(KomoditasActivity.this, "nama", null); intent = new Intent(KomoditasActivity.this, LoginActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); return true; case R.id.tentang: intent = new Intent(KomoditasActivity.this, TentangActivity.class); startActivity(intent); return true; default: return true; } startActivity(intent); finish(); return true; } }); recyclerView = (RecyclerView) findViewById(R.id.scrollableview); recyclerView.setHasFixedSize(true); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); recyclerView.setLayoutManager(linearLayoutManager); imageHeader = (ImageView) findViewById(R.id.header); imageHeader.setVisibility(View.GONE); fabButton = (FabButton) findViewById(R.id.determinate); fabButton.showProgress(true); new DownloadData().execute(); fabButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { fabButton.showProgress(true); new DownloadData().execute(); } }); }
From source file:com.example.inmarsat.hellomap.MainActivity.java
public void getLocationRequest() { RequestQueue queue = Volley.newRequestQueue(this); String url = mLocationSandboxEndpoint; JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() { @Override/*from w w w . java 2 s . co m*/ public void onResponse(JSONObject response) { // response Log.d("Response", response.toString()); double latitude; double longitude; try { latitude = response.getDouble("latitude"); longitude = response.getDouble("longitude"); } catch (Exception e) { return; } if (mMap != null) { mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(STJOHNS_LONDON, 0)); mMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)) .title("Latitude " + latitude + " Longitude " + longitude)); if (findViewById(R.id.detailsText) != null) { TextView view = (TextView) findViewById(R.id.detailsText); view.setText("Latitude " + latitude + " Longitude " + longitude); } } else { Log.d("Map Not Available", "ERROR"); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.d("ERROR", "error => " + error.toString()); if (error.networkResponse != null && error.networkResponse.data != null && findViewById(R.id.detailsText) != null) { TextView view = (TextView) findViewById(R.id.detailsText); view.setText("Error Code: " + error.networkResponse.statusCode); } else if (findViewById(R.id.detailsText) != null) { TextView view = (TextView) findViewById(R.id.detailsText); view.setText(error.toString()); } } }) { @Override public Map<String, String> getHeaders() throws AuthFailureError { Map<String, String> params = new HashMap<String, String>(); params.put("Authorization", mAuthorization); return params; } }; queue.add(getRequest); }
From source file:com.skubit.bitid.fragments.SignInResponseFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_signin_response, container, false); TextView messageView = (TextView) view.findViewById(R.id.message); final String message = getArguments().getString("message"); final int resultCode = getArguments().getInt("resultCode"); if (resultCode == ResultCode.OK) { messageView.setText("Login successful"); } else {//from w w w .j a va 2s. c o m messageView.setText(getMessageValue(message)); } Button done = (Button) view.findViewById(R.id.doneBtn); done.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mAuthCallbacks != null) { mAuthCallbacks.sendResultsBackToCaller(resultCode, message); } } }); return view; }
From source file:gov.in.bloomington.georeporter.fragments.ReportFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); TextView service_description = (TextView) getView().findViewById(R.id.service_description); service_description.setText(mService.optString(Open311.DESCRIPTION)); // Inflate all the views for the service attributes if (mService.optBoolean(Open311.METADATA)) { LinearLayout layout = (LinearLayout) getView().findViewById(R.id.attributes); JSONObject definition = Open311.sServiceDefinitions.get(mService.opt(Open311.SERVICE_CODE)); JSONArray attributes = definition.optJSONArray(Open311.ATTRIBUTES); int len = attributes.length(); for (int i = 0; i < len; i++) { JSONObject a = attributes.optJSONObject(i); View v = loadViewForAttribute(a, savedInstanceState); if (v != null) { String description = a.optString(Open311.DESCRIPTION); TextView label = (TextView) v.findViewById(R.id.label); label.setText(description); layout.addView(v);/*from www . j a v a 2 s .co m*/ } } } }