List of usage examples for android.widget TextView setText
@android.view.RemotableViewMethod public final void setText(@StringRes int resid)
From source file:eu.thecoder4.gpl.pleftdroid.HandleLinksActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText("Verifying Link..."); setContentView(tv);/*from w w w.ja v a 2 s . co m*/ Intent intent = getIntent(); if (intent.getAction().equals("android.intent.action.VIEW")) { try { Uri uri = getIntent().getData(); theurl = uri.toString(); } catch (Exception e) { Toast.makeText(this, R.string.toast_couldnotopenurl, Toast.LENGTH_LONG).show(); } } else if (Intent.ACTION_SEND.equals(intent.getAction())) { Bundle extras = intent.getExtras(); theurl = extras.getCharSequence(Intent.EXTRA_TEXT).toString(); } else { theurl = ""; } //Toast.makeText(this, "The URL = "+theurl, Toast.LENGTH_LONG).show(); // Parse the URL // VERIFICATION: verify?id=&u=&p= // INVITATION: a?id=&u=&p= if (theurl.indexOf("?") < 0 && theurl.indexOf("/verify?") < 0 && theurl.indexOf("/a?") < 0) { Toast.makeText(this, R.string.toast_linknotsupp, Toast.LENGTH_LONG).show(); finish(); } else { Map<String, String> arr = PleftBroker.getParamsFromURL(theurl); pserver = arr.get("pserver"); if (arr.get("id") != null) { aid = Integer.parseInt(arr.get("id")); } else { aid = 0; } vcode = arr.get("p"); user = arr.get("u"); if (aid == 0 || vcode == null || user == null) { Toast.makeText(this, R.string.toast_shlinknotvalid, Toast.LENGTH_LONG).show(); finish(); } else { // we have a valid Link handleLnk = new Runnable() { @Override public void run() { handleLink(); } }; Thread thread = new Thread(null, handleLnk, "Handlethrd"); thread.start(); } // End - if Link is Valid } }
From source file:com.example.android.soonami.MainActivity.java
/** * Update the screen to display information from the given {@link Event}. *//*from w w w .ja v a 2 s. c om*/ private void updateUi(Event earthquake) { // Display the earthquake title in the UI TextView titleTextView = (TextView) findViewById(R.id.title); titleTextView.setText(earthquake.title); // Display the earthquake date in the UI TextView dateTextView = (TextView) findViewById(R.id.date); dateTextView.setText(getDateString(earthquake.time)); // Display whether or not there was a tsunami alert in the UI TextView tsunamiTextView = (TextView) findViewById(R.id.tsunami_alert); tsunamiTextView.setText(getTsunamiAlertString(earthquake.tsunamiAlert)); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppReferenceObj.java
public void render(final Context context, final ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();//from w w w . j ava2 s . c om // TODO: hack to show object history in app feeds SignedObj appState = getAppStateForChildFeed(context, obj); if (appState != null) { mAppStateObj.render(context, frame, obj, allowInteractions); return; } else { String appName = content.optString(PACKAGE_NAME); if (appName.contains(".")) { // TODO: look up label. appName = appName.substring(appName.lastIndexOf(".") + 1); } String text = "Welcome to " + appName + "!"; TextView valueTV = new TextView(context); valueTV.setText(text); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); frame.addView(valueTV); } }
From source file:com.travelguide.GuideActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); final String TAG = "Activity2"; String ln = getIntent().getExtras().getString("tag"); if ((ln.equals("Espaol")) || (ln.equals("Spanish"))) { TextView t1 = (TextView) findViewById(R.id.thanks); t1.setText("Gracias por usar mi aplicacin."); TextView t2 = (TextView) findViewById(R.id.link); t2.setText("Las ubicaciones de visitantes en el interior " + getIntent().getExtras().getString("com.travelguide.radius") + " millas para " + getIntent().getExtras().getString("com.travelguide.location")); } else {//from w w w.j a va2s . c o m TextView t1 = (TextView) findViewById(R.id.thanks); t1.setText("Thanks for using my App."); TextView t2 = (TextView) findViewById(R.id.link); t2.setText( "Visitor locations found within " + getIntent().getExtras().getString("com.travelguide.radius") + " miles for " + getIntent().getExtras().getString("com.travelguide.location")); } String url = getIntent().getExtras().getString("com.travelguide.link"); Log.i(TAG, url); try { //***** Parsing the xml file***** SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); tgparse myXML_parser = new tgparse(); xr.setContentHandler(myXML_parser); HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet(url.replace(" ", "%20")); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String responseBody = httpclient.execute(httpget, responseHandler); Log.i(TAG, "responseBody: " + responseBody); ByteArrayInputStream is = new ByteArrayInputStream(responseBody.getBytes()); xr.parse(new InputSource(is)); Log.i(TAG, "parse complete"); TextView placename[]; TextView placeaddress[]; TextView placerating[]; tgxml data; data = tgparse.getXMLData(); placename = new TextView[data.getName().size()]; placeaddress = new TextView[data.getName().size()]; placerating = new TextView[data.getName().size()]; webview = (WebView) findViewById(R.id.myWebView); // webview.setBackgroundColor(0); // webview.setBackgroundResource(R.drawable.openbook); String stg1 = new String(); stg1 = "<html>"; for (int i = 1; i < (data.getName().size()); i++) { Log.i(TAG, " " + i); Log.i(TAG, "Name= " + data.getName().get(i)); Log.i(TAG, "Address= " + data.getAddress().get(i)); Log.i(TAG, "Rating= " + data.getRating().get(i)); placename[i] = new TextView(this); placename[i].setText("Name= " + data.getName().get(i)); placeaddress[i] = new TextView(this); placeaddress[i].setText("Address= " + data.getAddress().get(i)); placerating[i] = new TextView(this); placerating[i].setText("Rating= " + data.getRating().get(i)); if ((ln.equals("Espaol")) || (ln.equals("Spanish"))) { stg1 = stg1 + "Nombre: " + data.getName().get(i) + "<br>" + " Direccin: " + data.getAddress().get(i) + "<br>" + " clasificacin= " + data.getRating().get(i) + "<br>" + "<br>"; } else { stg1 = stg1 + "Name: " + data.getName().get(i) + "<br>" + " Address: " + data.getAddress().get(i) + "<br>" + " Rating= " + data.getRating().get(i) + "<br>" + "<br>"; } } stg1 = stg1 + "</html>"; webview.loadDataWithBaseURL(null, stg1, "text/html", "utf-8", "about:blank"); } catch (Exception e) { Log.i(TAG, "Exception caught", e); } }
From source file:net.kidlogger.kidlogger.SendTestReport.java
@Override protected void onBindView(View view) { super.onBindView(view); testRes = (TextView) view.findViewById(R.id.test_result); testRes.setText(context.getString(R.string.str_send_message)); sendTest = (Button) view.findViewById(R.id.send_test_report); sendTest.setOnClickListener(new OnClickListener() { public void onClick(View view) { testRes.setText(context.getString(R.string.str_wait_message)); sendPOST();//from w ww. j a va 2s . c om restartService(); } }); String file = ""; String status = ""; if (KLService.SIZE_SENT > 0) { //file = KLService.FILE_SENT + " (" + KLService.SIZE_SENT + " b)"; file = new String(KLService.FILE_SENT) + " (" + KLService.SIZE_SENT + " b)"; //status = KLService.pStatus; status = new String(KLService.pStatus); } TextView fileSent = (TextView) view.findViewById(R.id.sent_file_name); fileSent.setText(file); TextView sentStatus = (TextView) view.findViewById(R.id.sent_status); sentStatus.setText(status); TextView sendTime = (TextView) view.findViewById(R.id.send_time); sendTime.setText(app.mSendTime); // Show delivery queue TextView deliveryQueue = (TextView) view.findViewById(R.id.delivery_queue); deliveryQueue.setText(getQueueList()); // Show uploaded media file size TextView uploadedSize = (TextView) view.findViewById(R.id.uploaded_size); uploadedSize.setText(String.format("%.2f", (KLService.uploadedSize / 1000000f))); //uploadedSize.setText(String.valueOf(KLService.uploadedSize)); }
From source file:net.idlesoft.android.apps.github.activities.BranchesList.java
@Override public void onCreate(final Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.branch_list); mPrefs = getSharedPreferences(Hubroid.PREFS_NAME, 0); mEditor = mPrefs.edit();// w w w . j ava 2s. c om mUsername = mPrefs.getString("username", ""); mPassword = mPrefs.getString("password", ""); mGapi.authenticate(mUsername, mPassword); mLoadView = getLayoutInflater().inflate(R.layout.loading_listitem, null); mBranchList = (ListView) findViewById(R.id.lv_branchList_list); mBranchList.setOnItemClickListener(mOnBranchListItemClick); ((ImageButton) findViewById(R.id.btn_search)).setOnClickListener(new OnClickListener() { public void onClick(final View v) { startActivity(new Intent(BranchesList.this, Search.class)); } }); final TextView title = (TextView) findViewById(R.id.tv_page_title); title.setText("Branches"); final Bundle extras = getIntent().getExtras(); if (extras != null) { mRepoName = extras.getString("repo_name"); mRepoOwner = extras.getString("repo_owner"); mGetBranchesTask = (GetBranchesTask) getLastNonConfigurationInstance(); if (mGetBranchesTask == null) { mGetBranchesTask = new GetBranchesTask(); } mGetBranchesTask.activity = this; if ((mGetBranchesTask.getStatus() == AsyncTask.Status.PENDING) && (mBranchListAdapter == null)) { mGetBranchesTask.execute(); } } }
From source file:com.manning.androidhacks.hack026.SectionAdapter.java
@Override public View getView(int position, View view, ViewGroup parent) { if (view == null) { view = activity.getLayoutInflater().inflate(R.layout.list_item, parent, false); }/*from www . ja v a 2 s .c om*/ TextView header = (TextView) view.findViewById(R.id.header); String label = getItem(position); if (position == 0 || getItem(position - 1).charAt(0) != label.charAt(0)) { header.setVisibility(View.VISIBLE); header.setText(label.substring(0, 1)); } else { header.setVisibility(View.GONE); } return super.getView(position, view, parent); }
From source file:com.brodev.socialapp.view.BlogDetail.java
private void initView() { ImageView userImage = (ImageView) this.findViewById(R.id.image_user); if (!"".equals(blog.getUser_image_path())) { networkUntil.drawImageUrl(userImage, blog.getUser_image_path(), R.drawable.loading); }//from w w w . j a v a 2 s .co m // set title TextView title = (TextView) this.findViewById(R.id.title); title.setText(blog.getTitle()); colorView.changeColorText(title, user.getColor()); // set content TextView content = (TextView) this.findViewById(R.id.blog_content_detail); // interesting part starts from here here: Html.ImageGetter ig = imageGetter.create(0, blog.getText(), content); content.setTag(0); content.setText(Html.fromHtml(blog.getText(), ig, null)); TextView timestamp = (TextView) findViewById(R.id.time_stamp); timestamp.setText(blog.getTime_stamp()); // set short text TextView shortText = (TextView) findViewById(R.id.fullName); shortText.setText(blog.getFull_name()); TextView total_like = (TextView) findViewById(R.id.total_like); total_like.setText(String.valueOf(blog.getTotal_like())); colorView.changeColorText(total_like, user.getColor()); TextView total_comment = (TextView) findViewById(R.id.total_comment); total_comment.setText(String.valueOf(blog.getTotal_comment())); colorView.changeColorText(total_comment, user.getColor()); ImageView likeImg = (ImageView) this.findViewById(R.id.likes_feed_txt); ImageView commentImg = (ImageView) this.findViewById(R.id.comments_feed_txt); colorView.changeColorLikeCommnent(likeImg, commentImg, user.getColor()); }
From source file:com.ubikod.capptain.android.sdk.reach.activity.CapptainPollActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { /* Init layout */ super.onCreate(savedInstanceState); /* If no content, nothing to do, super class already called finish */ if (mContent == null) return;/*from w w w . ja v a2 s . c om*/ /* Render questions */ LinearLayout questionsLayout = getView("questions"); JSONArray questions = mContent.getQuestions(); LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); try { for (int i = 0; i < questions.length(); i++) { /* Get question */ JSONObject question = questions.getJSONObject(i); /* Inflate question layout */ LinearLayout questionLayout = (LinearLayout) layoutInflater .inflate(getLayoutId("capptain_poll_question"), null); /* Set question's title */ TextView questionTitle = (TextView) questionLayout.findViewById(getId("question_title")); questionTitle.setText(question.getString("title")); /* Set choices */ RadioGroup choicesView = (RadioGroup) questionLayout.findViewById(getId("choices")); choicesView.setTag(question); JSONArray choices = question.getJSONArray("choices"); int choiceViewId = 0; for (int j = 0; j < choices.length(); j++) { /* Get choice */ JSONObject choice = choices.getJSONObject(j); /* Inflate choice layout */ RadioButton choiceView = (RadioButton) layoutInflater .inflate(getLayoutId("capptain_poll_choice"), null); /* Each choice is a radio button */ choiceView.setId(choiceViewId++); choiceView.setTag(choice.getString("id")); choiceView.setText(choice.getString("title")); choiceView.setChecked(choice.getBoolean("default")); choicesView.addView(choiceView); } /* Add to parent layouts */ questionsLayout.addView(questionLayout); /* Watch state */ mRadioGroups.add(choicesView); choicesView.setOnCheckedChangeListener(mRadioGroupListener); } } catch (JSONException jsone) { /* Won't happen */ } /* Disable action if a choice is not selected */ updateActionState(); }
From source file:com.ateam.alleneatonautorentals.SalesPrintContract.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sales_print_contract); Intent getIntent = getIntent();/*from w w w . j a v a 2s . co m*/ userEmail = getIntent.getStringExtra("email"); name = getIntent.getStringExtra("name"); key = getIntent.getStringExtra("key"); carid = getIntent.getStringExtra("carid"); gps = getIntent.getStringExtra("gps"); ktag = getIntent.getStringExtra("ktag"); childseat = getIntent.getStringExtra("child_seat"); assistance = getIntent.getStringExtra("assistance"); dinsurance = getIntent.getStringExtra("dinsurance"); ainsurance = getIntent.getStringExtra("ainsurance"); start_date = getIntent.getStringExtra("start_date"); end_date = getIntent.getStringExtra("end_date"); city = getIntent.getStringExtra("city"); state = getIntent.getStringExtra("state"); eemail = getIntent.getStringExtra("eemail"); car_type = getIntent.getStringExtra("cartype"); car_model = getIntent.getStringExtra("carmodel"); car_make = getIntent.getStringExtra("carmake"); license_plate = getIntent.getStringExtra("lplate"); license_state = getIntent.getStringExtra("lstate"); car_year = getIntent.getStringExtra("caryear"); checkin = getIntent.getStringExtra("checkin"); card_number = getIntent.getStringExtra("cardnumber"); Map<String, Object> params = new HashMap<String, Object>(); params.put("Car Type", car_type.substring(10)); params.put("GPS Receiver", gps.substring(5)); params.put("Child Seats", childseat.substring(12)); params.put("K-Tag Rental", ktag.substring(7)); params.put("Roadside Assistance", assistance.substring(17)); params.put("Loss Damage Waiver Insurance", dinsurance.substring(18)); params.put("Personal Accident Insurance", ainsurance.substring(20)); params.put("Start Date", start_date.substring(24)); params.put("End Date", end_date.substring(22)); params.put("City", city.substring(18)); params.put("State", state.substring(19)); params.put("Checkin Date", checkin.substring(15)); PriceManager priceManager = new PriceManager(params); Double price = priceManager.getContractPrice(); DecimalFormat df = new DecimalFormat("#.00"); TextView tview = (TextView) findViewById(R.id.contract_user_name); tview.setText(name); tview = (TextView) findViewById(R.id.contract_user_email); tview.setText(userEmail); tview = (TextView) findViewById(R.id.contract_card_number); tview.setText(card_number); tview = (TextView) findViewById(R.id.contract_employee_email); tview.setText(eemail); tview = (TextView) findViewById(R.id.contract_car_id); tview.setText(carid); tview = (TextView) findViewById(R.id.contract_car_type); tview.setText(car_type); tview = (TextView) findViewById(R.id.contract_car_make); tview.setText(car_make); tview = (TextView) findViewById(R.id.contract_car_model); tview.setText(car_model); tview = (TextView) findViewById(R.id.contract_car_year); tview.setText(car_year); tview = (TextView) findViewById(R.id.contract_license_plate); tview.setText(license_plate); tview = (TextView) findViewById(R.id.contract_license_plate_state); tview.setText(license_state); tview = (TextView) findViewById(R.id.contract_start_date); tview.setText(start_date); tview = (TextView) findViewById(R.id.contract_end_date); tview.setText(end_date); tview = (TextView) findViewById(R.id.contract_city_reservation); tview.setText(city); tview = (TextView) findViewById(R.id.contract_state_reservation); tview.setText(state); //tview = (TextView)findViewById(R.id.contract_price); //tview.setText(userEmail); tview = (TextView) findViewById(R.id.contract_gps); tview.setText(gps); tview = (TextView) findViewById(R.id.contract_ktag); tview.setText(ktag); tview = (TextView) findViewById(R.id.contract_child_seat); tview.setText(childseat); tview = (TextView) findViewById(R.id.contract_assistence); tview.setText(assistance); tview = (TextView) findViewById(R.id.contract_dinsurance); tview.setText(dinsurance); tview = (TextView) findViewById(R.id.contract_ainsurance); tview.setText(ainsurance); tview = (TextView) findViewById(R.id.contract_checkin_date); tview.setText(checkin); tview = (TextView) findViewById(R.id.total_price); tview.setText("$" + df.format(price)); }