List of usage examples for android.widget TextView getText
@ViewDebug.CapturedViewProperty
public CharSequence getText()
From source file:com.gimranov.zandy.app.ItemActivity.java
/** * Called when the activity is first created. *//* w w w . j a v a 2 s. c o m*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String persistedSort = Persistence.read(SORT_CHOICE); if (persistedSort != null) sortBy = persistedSort; db = new Database(this); setContentView(R.layout.items); Intent intent = getIntent(); collectionKey = intent.getStringExtra("com.gimranov.zandy.app.collectionKey"); ItemCollection coll = ItemCollection.load(collectionKey, db); APIRequest req; if (coll != null) { req = APIRequest.fetchItems(coll, false, new ServerCredentials(this)); } else { req = APIRequest.fetchItems(false, new ServerCredentials(this)); } prepareAdapter(); ItemAdapter adapter = (ItemAdapter) getListAdapter(); Cursor cur = adapter.getCursor(); if (intent.getBooleanExtra("com.gimranov.zandy.app.rerequest", false) || cur == null || cur.getCount() == 0) { if (!ServerCredentials.check(getBaseContext())) { Toast.makeText(getBaseContext(), getResources().getString(R.string.sync_log_in_first), Toast.LENGTH_SHORT).show(); return; } Toast.makeText(this, getResources().getString(R.string.collection_empty), Toast.LENGTH_SHORT).show(); Log.d(TAG, "Running a request to populate missing items"); ZoteroAPITask task = new ZoteroAPITask(this); req.setHandler(mEvent); task.execute(req); } ListView lv = getListView(); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // If we have a click on an item, do something... ItemAdapter adapter = (ItemAdapter) parent.getAdapter(); Cursor cur = adapter.getCursor(); // Place the cursor at the selected item if (cur.moveToPosition(position)) { // and load an activity for the item Item item = Item.load(cur); Log.d(TAG, "Loading item data with key: " + item.getKey()); // We create and issue a specified intent with the necessary data Intent i = new Intent(getBaseContext(), ItemDataActivity.class); i.putExtra("com.gimranov.zandy.app.itemKey", item.getKey()); i.putExtra("com.gimranov.zandy.app.itemDbId", item.dbId); startActivity(i); } else { // failed to move cursor-- show a toast TextView tvTitle = (TextView) view.findViewById(R.id.item_title); Toast.makeText(getApplicationContext(), getResources().getString(R.string.cant_open_item, tvTitle.getText()), Toast.LENGTH_SHORT).show(); } } }); }
From source file:com.contentful.discovery.ui.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTextColor(tabTextColor); // setAllCaps() is only available from API 14, so the upper case is made manually if we // are on a pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); }//from w w w .j a va2 s . c o m } } } }
From source file:com.hybris.mobile.activity.AbstractProductDetailActivity.java
/** * Refresh the UI with data from the product *///from w w w . j av a 2 s. co m public void updateUI() { // Title this.setTitle(mProduct.getName()); // Images if (mProduct.getGalleryImageURLs() != null) { GalleryAdapter adapter = new GalleryAdapter(this, mProduct.getGalleryImageURLs()); Gallery gallery = (Gallery) findViewById(R.id.galleryImages); gallery.setAdapter(adapter); // Set the onClick listener for the gallery gallery.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long arg3) { viewImage(position); } }); } // Reviews TextView reviewTextView = (TextView) findViewById(R.id.textViewReviews); reviewTextView.setText(this.getResources().getString(R.string.show_reviews, mProduct.getReviews().size())); // Rating (stars) RatingBar ratingBar = (RatingBar) findViewById(R.id.ratingBarRating); if (mProduct.getAverageRating() != null) { ratingBar.setRating(mProduct.getAverageRating().floatValue()); } // Promotions TextView promotionsTextView = (TextView) findViewById(R.id.textViewPromotion); if (mProduct.getPotentialPromotions().size() == 0) { promotionsTextView.setVisibility(View.GONE); } else { if (mProduct.getPotentialPromotions() != null && !mProduct.getPotentialPromotions().isEmpty()) { promotionsTextView.setText( Html.fromHtml(Product.generatePromotionString(mProduct.getPotentialPromotions().get(0)))); StringUtil.removeUnderlines((Spannable) promotionsTextView.getText()); } } TextView priceTextView = (TextView) findViewById(R.id.textViewPrice); priceTextView.setText(mProduct.getPrice().getFormattedValue()); // Description TextView descriptionTextView = (TextView) findViewById(R.id.textViewDescription); descriptionTextView.setText(mProduct.getDescription()); // Stock level TextView stockLevelTextView = (TextView) findViewById(R.id.textViewStockLevel); String stockLevelText = mProduct.getStockLevelText(Hybris.getAppContext()); if (mProduct.getStock().getStockLevel() > 0) { stockLevelText = mProduct.getStock().getStockLevel() + " " + mProduct.getStockLevelText(Hybris.getAppContext()).toLowerCase(); } stockLevelTextView.setText(stockLevelText); // Disable / Enable the add to cart button Button addToCartButton = (Button) findViewById(R.id.buttonAddToCart); Button quantityButton = (Button) findViewById(R.id.quantityButton); quantityButton.setText(getString(R.string.quantity_button, quantityToAddToCart)); try { if (mProduct.getStock().getStockLevelStatus() != null && StringUtils.equalsIgnoreCase(mProduct.getStock().getStockLevelStatus().getCode(), ProductStockLevelStatus.CODE_OUT_OF_STOCK)) { addToCartButton.setEnabled(false); quantityButton.setEnabled(false); quantityButton.setText(R.string.quantity); } else { addToCartButton.setEnabled(true); quantityButton.setEnabled(true); } } catch (Exception e) { } invalidateOptionsMenu(); }
From source file:com.github.michalbednarski.intentslab.editor.IntentGeneralFragment.java
@Override public void updateEditedIntent(Intent editedIntent) { // Intent action if (mAvailbleActions != null) { editedIntent.setAction((String) mActionsSpinner.getSelectedItem()); } else {/* ww w . j a v a 2s . c om*/ String action = mActionText.getText().toString(); if ("".equals(action)) { action = null; } editedIntent.setAction(action); } // Categories { // Clear categories (why there's no api for this) Set<String> origCategories = editedIntent.getCategories(); if (origCategories != null) { for (String category : origCategories.toArray(new String[origCategories.size()])) { editedIntent.removeCategory(category); } } } // Fill categories if (mCategoryCheckBoxes != null) { // Fill categories from checkboxes for (CheckBox cb : mCategoryCheckBoxes) { String category = (String) cb.getTag(); if (cb.isChecked()) { editedIntent.addCategory(category); } } } else { // Fill categories from textfields for (TextView categoryTextView : mCategoryTextInputs) { editedIntent.addCategory(categoryTextView.getText().toString()); } } // Intent data (Uri) and type (MIME) String data = mDataText.getText().toString(); editedIntent.setDataAndType(data.equals("") ? null : Uri.parse(data), getDataType()); // Package name { String packageName = mPackageNameText.getText().toString(); if ("".equals(packageName)) { editedIntent.setPackage(null); } else { editedIntent.setPackage(packageName); } } // Set component for explicit intent updateIntentComponent(); }
From source file:com.ijiaban.tabslide.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(tabTextColor); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); }/*w w w . j a v a 2 s .c o m*/ } } } }
From source file:com.cmput301w15t15.travelclaimsapp.activitys.EditClaimActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case R.id.cmenu_dlist_delete: ClaimListController.removeDestination(destAdaptor.getItem(info.position), theClaim); destAdaptor.notifyDataSetChanged(); return true; case R.id.cmenu_dlist_edit: //show a dialog for editing destinations final EditText enterLocation = new EditText(this); final EditText enterReason = new EditText(this); enterLocation.setText(destAdaptor.getItem(info.position).getLocation()); enterReason.setText(destAdaptor.getItem(info.position).getReason()); enterLocation.setHint("Enter location"); enterReason.setHint("Enter reason"); LinearLayout linearLayout = new LinearLayout(this); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(enterLocation); linearLayout.addView(enterReason); AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setView(linearLayout);// w ww . ja v a 2 s . co m alert.setPositiveButton("Add", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { destAdaptor.getItem(info.position).setLocation(enterLocation.getText().toString()); destAdaptor.getItem(info.position).setReason(enterReason.getText().toString()); destAdaptor.notifyDataSetChanged(); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); alert.show(); return true; case R.id.cmenu_dlist_geolocation: adaptorPos = info.position; AlertDialog.Builder alertGl = new AlertDialog.Builder(this); alertGl.setPositiveButton("GPS", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (GeoLocationController.checkGPSEnabled()) { GeoLocationController.setDestinationGeoLocationGPS(destAdaptor.getItem(info.position)); destAdaptor.notifyDataSetChanged(); } } }); alertGl.setNegativeButton("Map", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Open map view \ Intent intent = GeoLocationController.pickLocationIntent(EditClaimActivity.this); startActivityForResult(intent, GET_GEOLOCATION_CODE); } }); alertGl.show(); return true; case R.id.cmenu_delete_tag: ClaimListController.removeTag(theClaim, tagAdaptor.getItem(info.position)); tagAdaptor.notifyDataSetChanged(); return true; case R.id.cmenu_rename_tag: //create a Alert dialog for editing tag name final TextView enterTag = new AutoCompleteTextView(this); enterTag.setHint("Enter tag"); AlertDialog.Builder alertTag = new AlertDialog.Builder(this); alertTag.setView(enterTag); alertTag.setPositiveButton("Add", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { tagAdaptor.getItem(info.position).setName(enterTag.getText().toString()); tagAdaptor.notifyDataSetChanged(); } }); alertTag.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); alertTag.show(); return true; default: return super.onContextItemSelected(item); } }
From source file:com.ProfessorPopTart.alternateouyastore.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GameList = new ArrayList<String>(); GameListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, GameList); final ListView myListView = (ListView) findViewById(R.id.appsLBX); final TextView myGameName = (TextView) findViewById(R.id.gameName); myListView.setAdapter(GameListAdapter); myListView.setTextFilterEnabled(true); //assign onclick event to getListBTN Button myGetListBTN = (Button) findViewById(R.id.getListBTN); myGetListBTN.setOnClickListener(new OnClickListener() { public void onClick(View v) { populateList();//ww w .j a va 2 s. c o m } }); //assign onclick event to downloadGameBTN Button myDownloadBTN = (Button) findViewById(R.id.donwloadBTN); myDownloadBTN.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { buildDownloadRequest(myGameName.getText().toString()); } }); //assign onSelected event to appsLBX myListView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { String selectedFromList = (myListView.getItemAtPosition(i).toString()); displayImage(getImgUrl(selectedFromList)); myGameName.setText(selectedFromList); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); }
From source file:com.example.jingzhongjie.tabbarviewtest.widget.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, Typeface.NORMAL); tab.setTextColor(defaultTextColor); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); }//ww w .j av a2s . co m } } } }
From source file:com.example.fan.horizontalscrollview.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setLayoutParams(defaultTabLayoutParams); v.setBackgroundResource(tabBackgroundResId); v.setPadding(tabPadding, 0, tabPadding, 0); if (v instanceof TextView || v instanceof RelativeLayout) { TextView tab = null; if (v instanceof TextView) tab = (TextView) v;/*from w w w.ja v a 2 s.com*/ else tab = (TextView) v.findViewById(R.id.pst_tv_tab); tab.setTypeface(tabTypeface, tabTypefaceStyle); if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); } } } } }
From source file:cz.zcu.kiv.eeg.mobile.base.ui.scenario.ScenarioAddActivity.java
@Override protected void save() { //obtaining layout elements Spinner group = (Spinner) findViewById(R.id.groupList); EditText scenarioName = (EditText) findViewById(R.id.scenario_name_value); EditText description = (EditText) findViewById(R.id.scenario_description_value); EditText mime = (EditText) findViewById(R.id.scenario_mime_value); TextView fileName = (TextView) findViewById(R.id.fchooserSelectedFile); CompoundButton isPrivate = (CompoundButton) findViewById(R.id.scenario_private); SharedPreferences getOwner = getSharedPreferences(Values.PREFS_TEMP, Context.MODE_PRIVATE); String loggeduserDocID = getOwner.getString("loggedUserDocID", null); String loggeduserName = getOwner.getString("loggedUserName", null); //creating scenario instance Scenario scenario = new Scenario(); scenario.setScenarioName(scenarioName.getText().toString()); scenario.setResearchGroupId(//from w w w . j a v a 2 s . co m group.getSelectedItem() == null ? null : ((ResearchGroup) group.getSelectedItem()).getGroupId()); scenario.setDescription(description.getText().toString()); scenario.setMimeType(mime.getText().toString()); scenario.setFileName(fileName.getText().toString()); scenario.setPrivate(isPrivate.isChecked()); scenario.setFilePath(selectedFile); scenario.setFileLength(String.valueOf(selectedFileLength)); scenario.setOwnerId(loggeduserDocID); scenario.setOwnerUserName(loggeduserName); validateAndRun(scenario); }