List of usage examples for android.widget TextView setText
@android.view.RemotableViewMethod public final void setText(@StringRes int resid)
From source file:org.mifos.androidclient.main.CollectionSheetActivity.java
protected void updateContent(CollectionSheetData collectionSheet) { if (collectionSheet != null) { mCollectionSheetData = collectionSheet; TextView textView = (TextView) findViewById(R.id.collectionSheet_centerInfo); textView.setText(" + " + mCenter.getDisplayName()); textView.setOnTouchListener(this); if (CollectionSheetHolder.getCollectionSheetData() == null) { mCollectionSheetData = collectionSheet; } else {/*from w w w. j a va 2s. c o m*/ mCollectionSheetData = CollectionSheetHolder.getCollectionSheetData(); } mSelectedCustomer = CollectionSheetHolder.getCurrentCustomer(); if (mSelectedCustomer != null) { updateCustomers(collectionSheet); } if (collectionSheet.getCollectionSheetCustomer() != null && collectionSheet.getCollectionSheetCustomer().size() > 0) { ExpandableListView expandableListView = (ExpandableListView) findViewById( R.id.collectionSheet_entries); CollectionSheetExpandableListAdapter adapter = new CollectionSheetExpandableListAdapter( mCollectionSheetData, this); expandableListView.setAdapter(adapter); expandableListView.setOnItemLongClickListener(this); expandableListView.setOnChildClickListener(this); ArrayList<SaveCollectionSheetCustomer> saveCollectionSheetCustomers = new ArrayList<SaveCollectionSheetCustomer>(); prepareSaveCollectionSheet(saveCollectionSheetCustomers); CollectionSheetHolder.getSaveCollectionSheet(); mSaveCustomer.setSaveCollectionSheetCustomers(saveCollectionSheetCustomers); CollectionSheetHolder.setSaveCollectionSheet(mSaveCustomer); CollectionSheetHolder.setCollectionSheetData(mCollectionSheetData); } } }
From source file:com.scigames.slidegame.Registration5EmailActivity.java
/** Called with the activity is first created. */ @Override/* w ww. j av a 2 s . com*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "super.OnCreate"); Intent i = getIntent(); Log.d(TAG, "getIntent"); firstNameIn = i.getStringExtra("fName"); lastNameIn = i.getStringExtra("lName"); studentIdIn = i.getStringExtra("studentId"); visitIdIn = i.getStringExtra("visitId"); Log.d(TAG, "...getStringExtra"); // Inflate our UI from its XML layout description. setContentView(R.layout.registration5_email); Log.d(TAG, "...setContentView"); email = (EditText) findViewById(R.id.email); /* to hide the keyboard on launch, then open when tap in firstname field */ email.setInputType(InputType.TYPE_NULL); email.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { email.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); email.onTouchEvent(event); // call native handler return true; // consume touch even } }); Log.d(TAG, "...instantiateEditTexts"); //display name in greeting sentence Resources res = getResources(); TextView greets = (TextView) findViewById(R.id.greeting); greets.setText(String.format(res.getString(R.string.greeting), firstNameIn, lastNameIn)); Log.d(TAG, greets.toString()); Log.d(TAG, "...Greetings"); // Hook up button presses to the appropriate event handler. ((Button) findViewById(R.id.back)).setOnClickListener(mBackListener); ((Button) findViewById(R.id.continue_button)).setOnClickListener(mContinueButtonListener); Log.d(TAG, "...instantiateButtons"); //set listener task.setOnResultsListener(this); }
From source file:mad.codeforcommunity.CalendarView.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.calendar);/*from w w w .j a va2 s. co m*/ month = Calendar.getInstance(); // onNewIntent(getIntent()); items = new ArrayList<String>(); adapter = new CalendarAdapter(this, month); GridView gridview = (GridView) findViewById(R.id.gridview); gridview.setAdapter(adapter); handler = new Handler(); handler.post(calendarUpdater); TextView title = (TextView) findViewById(R.id.title); title.setText(android.text.format.DateFormat.format("MMMM yyyy", month)); TextView previous = (TextView) findViewById(R.id.previous); previous.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (month.get(Calendar.MONTH) == month.getActualMinimum(Calendar.MONTH)) { month.set((month.get(Calendar.YEAR) - 1), month.getActualMaximum(Calendar.MONTH), 1); } else { month.set(Calendar.MONTH, month.get(Calendar.MONTH) - 1); } refreshCalendar(); } }); TextView next = (TextView) findViewById(R.id.next); next.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (month.get(Calendar.MONTH) == month.getActualMaximum(Calendar.MONTH)) { month.set((month.get(Calendar.YEAR) + 1), month.getActualMinimum(Calendar.MONTH), 1); } else { month.set(Calendar.MONTH, month.get(Calendar.MONTH) + 1); } refreshCalendar(); } }); gridview.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { TextView date = (TextView) v.findViewById(R.id.date); ImageView image = (ImageView) v.findViewById(R.id.date_icon); if (date instanceof TextView && !date.getText().equals("")) { if (image.getVisibility() == View.VISIBLE) { /*OLD CODE * Intent intent = new Intent(); String day = date.getText().toString(); if(day.length()==1) { day = "0"+day; } // return chosen date as string format intent.putExtra("date", android.text.format.DateFormat.format("yyyy-MM", month)+"-"+day); setResult(RESULT_OK, intent); finish(); */ Bundle extras = new Bundle(); String day = date.getText().toString(); if (day.length() == 1) { day = "0" + day; } // return chosen date as string format extras.putString("date", android.text.format.DateFormat.format("yyyy-MM", month) + "-" + day); Intent intent = new Intent(CalendarView.this, EventView.class); intent.putExtras(extras); startActivity(intent); } } } }); }
From source file:au.com.cybersearch2.classyfy.TitleSearchResultsActivityTest.java
@Test public void test_dynamic_layout() throws Exception { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSSSS", new Locale("en", "AU")); RecordCategory recordCategory = new RecordCategory(); Date created = sdf.parse("2014-02-05 18:45:46.145000"); Date modified = sdf.parse("2014-02-12 11:55:23.121000"); recordCategory.setCreated(created);//from w ww.ja v a 2 s.com recordCategory.setModified(modified); recordCategory.setCreator("admin"); recordCategory.setDescription("Information Technology"); recordCategory.setIdentifier("2014-1391586274589"); FieldDescriptor descriptionField = new FieldDescriptor(); descriptionField.setOrder(1); descriptionField.setName("description"); descriptionField.setTitle("Description"); FieldDescriptor createdField = new FieldDescriptor(); createdField.setOrder(2); createdField.setName("created"); createdField.setTitle("Created"); FieldDescriptor creatorField = new FieldDescriptor(); creatorField.setOrder(3); creatorField.setName("creator"); creatorField.setTitle("Creator"); FieldDescriptor modifiedField = new FieldDescriptor(); modifiedField.setOrder(4); modifiedField.setName("modified"); modifiedField.setTitle("Modified"); FieldDescriptor modifier = new FieldDescriptor(); modifier.setOrder(5); modifier.setName("modifier"); modifier.setTitle("Modifier"); FieldDescriptor identifierField = new FieldDescriptor(); identifierField.setOrder(6); identifierField.setName("identifier"); identifierField.setTitle("Identifier"); Set<FieldDescriptor> fieldSet = new TreeSet<FieldDescriptor>(); fieldSet.add(descriptionField); fieldSet.add(createdField); fieldSet.add(creatorField); fieldSet.add(modifiedField); fieldSet.add(modifier); fieldSet.add(identifierField); @SuppressWarnings("unchecked") Map<String, Object> valueMap = PropertyUtils.describe(recordCategory); titleSearchResultsActivity = (TitleSearchResultsActivity) controller.create().get(); LinearLayout dynamicLayout = new LinearLayout(titleSearchResultsActivity); dynamicLayout.setOrientation(LinearLayout.VERTICAL); int layoutHeight = LinearLayout.LayoutParams.MATCH_PARENT; int layoutWidth = LinearLayout.LayoutParams.WRAP_CONTENT; for (FieldDescriptor descriptor : fieldSet) { Object value = valueMap.get(descriptor.getName()); if (value == null) continue; TextView titleView = new TextView(titleSearchResultsActivity); titleView.setText(descriptor.getTitle()); TextView valueView = new TextView(titleSearchResultsActivity); valueView.setText(value.toString()); LinearLayout fieldLayout = new LinearLayout(titleSearchResultsActivity); fieldLayout.setOrientation(LinearLayout.HORIZONTAL); fieldLayout.addView(titleView, new LinearLayout.LayoutParams(layoutWidth, layoutHeight)); fieldLayout.addView(valueView, new LinearLayout.LayoutParams(layoutWidth, layoutHeight)); } }
From source file:com.bluetooth.activities.WiFiControl.java
public boolean handleMessage(Message msg) { // Update UI//w w w.j a va 2 s.co m switch (msg.what) { case BluetoothRemoteControlApp.MSG_1: TextView tv = (TextView) findViewById(msg.arg1); tv.setText(msg.obj.toString()); break; case BluetoothRemoteControlApp.MSG_READ: tvData.append(msg.obj.toString() + "\n"); log += msg.obj + "<br />"; break; case BluetoothRemoteControlApp.MSG_WRITE: tvData.append(msg.obj.toString() + "\n"); log += msg.obj + "<br />"; break; } return super.handleMessage(msg); }
From source file:at.alladin.rmbt.android.views.ResultQoSDetailView.java
@SuppressWarnings("unchecked") @Override/*w w w . j a va2s. co m*/ public void taskEnded(JSONArray result) { System.out.println("ResultQoSDetail taskEnded"); this.testResult = result; if (resultFetchEndTaskListener != null) { resultFetchEndTaskListener.taskEnded(result); } ProgressBar resultProgressBar = (ProgressBar) view.findViewById(R.id.progress_bar); TextView resultTextView = (TextView) view.findViewById(R.id.info_text); try { results = new QoSServerResultCollection(result); View successList = view.findViewById(R.id.qos_success_list); List<HashMap<String, String>> itemList = new ArrayList<HashMap<String, String>>(); int index = 0; for (QoSTestResultEnum type : QoSTestResultEnum.values()) { if (results.getQoSStatistics().getTestCounter(type) > 0) { HashMap<String, String> listItem = new HashMap<String, String>(); listItem.put("name", ConfigHelper.getCachedQoSNameByTestType(type, activity)); listItem.put("type_name", type.toString()); listItem.put("index", String.valueOf(index++)); itemList.add(listItem); } } ListAdapter valueList = new SimpleAdapter(activity, itemList, R.layout.qos_category_list_item, new String[] { "name" }, new int[] { R.id.name }); resultProgressBar.setVisibility(View.GONE); if (valueList.getCount() > 0) { //in case the view will change again: if (ListView.class.isAssignableFrom(successList.getClass())) { ((ListView) successList).setAdapter(valueList); ((ListView) successList).setOnItemClickListener(this); } else { ViewGroup vgList = (ViewGroup) successList; for (int i = 0; i < valueList.getCount(); i++) { View v = valueList.getView(i, null, null); QoSTestResultEnum key = QoSTestResultEnum .valueOf(((HashMap<String, String>) valueList.getItem(i)).get("type_name")); if (results.getQoSStatistics().getFailureCounter(key) > 0) { ImageView img = (ImageView) v.findViewById(R.id.status); img.setImageResource(R.drawable.traffic_lights_red); } TextView status = (TextView) v.findViewById(R.id.qos_type_status); status.setText((results.getQoSStatistics().getTestCounter(key) - results.getQoSStatistics().getFailedTestsCounter(key)) + "/" + results.getQoSStatistics().getTestCounter(key)); v.setOnClickListener(this); v.setTag(valueList.getItem(i)); vgList.addView(v); } } successList.invalidate(); resultTextView.setVisibility(View.GONE); successList.setVisibility(View.VISIBLE); } else { resultTextView.setText(R.string.result_qos_error_no_data_available); } } catch (Throwable t) { resultTextView.setText(R.string.result_qos_error_no_data_available); resultProgressBar.setVisibility(View.GONE); t.printStackTrace(); } }
From source file:org.mifos.androidclient.util.listadapters.SimpleExpandableListAdapter.java
@Override public View getGroupView(int groupPos, boolean isExpanded, View convertView, ViewGroup parent) { View row;//from w w w. j a v a2s . com if (convertView == null) { LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); row = inflater.inflate(R.layout.simple_list_group, parent, false); } else { row = convertView; } SimpleListItem item = (SimpleListItem) getGroup(groupPos); if (item != null) { TextView label = (TextView) row.findViewById(R.id.simple_list_item_label); if (getChildrenCount(groupPos) > 0) { label.setText(mContext.getString(R.string.clientsList_listGroupLabel_withChildren, item.getListLabel(), getChildrenCount(groupPos))); } else { label.setText(item.getListLabel()); } } synchronized (mExpandGroups) { if (mExpandGroups == true) { ExpandableListView list = (ExpandableListView) parent; list.expandGroup(groupPos); } } return row; }
From source file:com.manning.androidhacks.hack041.ArticleActivity.java
private void updateCommentCount(long count) { TextView commentCount = (TextView) findViewById(R.id.comment_count); commentCount.setText(String.format("Comments: %d", count)); }
From source file:edu.rowan.app.carousel.CarouselFeature.java
private void setupView() { imageView.setId(1);/* w w w. j a va 2s. co m*/ RelativeLayout.LayoutParams imageParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); imageParams.addRule(RelativeLayout.CENTER_HORIZONTAL); imageView.setLayoutParams(imageParams); // imageView.setAdjustViewBounds(true); Resources r = context.getResources(); int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics()); TextView descriptionView = new TextView(context); descriptionView.setId(2); descriptionView.setPadding(padding, 0, padding, padding); descriptionView.setText(description); descriptionView.setBackgroundColor(Color.argb(220, 63, 26, 10)); descriptionView.setTextColor(Color.WHITE); RelativeLayout.LayoutParams descParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); descParams.addRule(RelativeLayout.ALIGN_BOTTOM, imageView.getId()); carouselView.addView(descriptionView, descParams); TextView titleView = new TextView(context); titleView.setText(title); titleView.setPadding(padding, 0, padding, 0); RelativeLayout.LayoutParams titleParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); titleParams.addRule(RelativeLayout.ABOVE, descriptionView.getId()); titleView.setLayoutParams(titleParams); titleView.setTextColor(Color.WHITE); titleView.setShadowLayer(2, 3, 3, Color.argb(230, 0, 0, 0)); titleView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22); carouselView.addView(titleView); }
From source file:com.bt.download.android.gui.adapters.SearchResultListAdapter.java
protected void populateFilePart(View view, FileSearchResult sr) { ImageView fileTypeIcon = findView(view, R.id.view_bittorrent_search_result_list_item_filetype_icon); fileTypeIcon.setImageResource(getFileTypeIconId()); TextView adIndicator = findView(view, R.id.view_bittorrent_search_result_list_item_ad_indicator); adIndicator.setVisibility(View.GONE); TextView title = findView(view, R.id.view_bittorrent_search_result_list_item_title); title.setText(sr.getDisplayName()); // if marked as downloading // title.setTextColor(GlobalConstants.COLOR_DARK_BLUE); TextView fileSize = findView(view, R.id.view_bittorrent_search_result_list_item_file_size); if (sr.getSize() > 0) { fileSize.setText(UIUtils.getBytesInHuman(sr.getSize())); } else {// ww w . ja v a 2s . co m fileSize.setText(""); } TextView extra = findView(view, R.id.view_bittorrent_search_result_list_item_text_extra); extra.setText(FilenameUtils.getExtension(sr.getFilename())); TextView seeds = findView(view, R.id.view_bittorrent_search_result_list_item_text_seeds); seeds.setText(""); String license = sr.getLicense().equals(License.UNKNOWN) ? "" : " - " + sr.getLicense(); TextView sourceLink = findView(view, R.id.view_bittorrent_search_result_list_item_text_source); sourceLink.setText(sr.getSource() + license); // TODO: ask for design sourceLink.setTag(sr.getDetailsUrl()); sourceLink.setPaintFlags(sourceLink.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); sourceLink.setOnClickListener(linkListener); }