List of usage examples for android.widget TextView setText
@android.view.RemotableViewMethod public final void setText(@StringRes int resid)
From source file:com.scigames.slidegame.Registration3MassActivity.java
/** Called with the activity is first created. */ @Override/*ww w . j av a 2 s .com*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "super.OnCreate"); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); 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.registration3_mass); Log.d(TAG, "...setContentView"); // Find the text editor view inside the layout, because we // want to do various programmatic things with it. thisMass = (EditText) findViewById(R.id.mass); /* to hide the keyboard on launch, then open when tap in firstname field */ thisMass.setInputType(InputType.TYPE_NULL); thisMass.setOnTouchListener(new View.OnTouchListener() { //@Override public boolean onTouch(View v, MotionEvent event) { thisMass.setInputType(InputType.TYPE_CLASS_TEXT); thisMass.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"); //set info to what we know already //firstName.setText(firstNameIn); //lastName.setText(lastNameIn); // Hook up button presses to the appropriate event handler. ((Button) findViewById(R.id.back)).setOnClickListener(mBackListener); ((Button) findViewById(R.id.continue_button)).setOnClickListener(mContinueButtonListener); ((Button) findViewById(R.id.scan)).setOnClickListener(mScanButtonListener); Log.d(TAG, "...instantiateButtons"); //set listener task.setOnResultsListener(this); }
From source file:com.yonisamlan.android.metaqr.AttributionsActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView textView = new TextView(this); setContentView(textView);/*from w w w . j a v a2 s .c om*/ String html; try { html = IOUtils.toString(getResources().openRawResource(R.raw.licenses)); } catch (NotFoundException e) { e.printStackTrace(); html = "Error reading license."; } catch (IOException e) { e.printStackTrace(); html = "Error reading license."; } textView.setText(Html.fromHtml(html)); textView.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.fabernovel.alertevoirie.utils.JSONAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { Log.d(Constants.PROJECT_TAG, "getview position : " + position); switch (getItemViewType(position)) { case TYPE_ITEM: Log.d(Constants.PROJECT_TAG, "get item number " + position); View v;//from w ww .j a v a 2s .c om View[] subViews; if (convertView != null && convertView.getTag() != null) { v = convertView; subViews = (View[]) v.getTag(); } else { v = inflater.inflate(cellLayout, null); subViews = new View[to.length]; for (int i = 0; i < to.length; i++) { subViews[i] = v.findViewById(to[i]); } v.setTag(subViews); } try { for (int i = 0; i < subViews.length; i++) { View subView = subViews[i]; if (subView instanceof TextView) { String text; text = ((JSONObject) getItem(position)).getString(from[i]); ((TextView) subView).setText(text); } else if (subView instanceof ImageView) { // TODO download image } } } catch (Exception e) { Log.e(Constants.PROJECT_TAG, "Error getting views", e); } return v; case TYPE_CATEGORY: Log.d(Constants.PROJECT_TAG, "getCat : " + position); TextView tv; if (convertView != null && convertView instanceof TextView) { tv = (TextView) convertView; } else { tv = (TextView) inflater.inflate(categoryLayout, null); } tv.setText(categories.get(position)); return tv; default: return null; } }
From source file:de.hackerspacebremen.fragments.StatusFragment.java
@Override public void onStart() { super.onStart(); EventBus.getDefault().register(this); // initializing the statusview holder StatusViewHolder.init(this.getView()); StatusViewHolder.get().statusLayout.setOnLongClickListener(new OnLongClickListener() { @Override/*www . j a v a 2 s. c o m*/ public boolean onLongClick(View v) { if (statusAnimation != null) { statusAnimation.start(); } if (messageAnimation != null) { messageAnimation.start(); } StatusViewHolder.get().messageBlock.setVisibility(RelativeLayout.GONE); StatusViewHolder.get().imgStatus.setVisibility(ImageView.VISIBLE); StatusViewHolder.get().imgConnErr.setVisibility(ImageView.GONE); final TextView text = StatusViewHolder.get().statusMessage; text.setTypeface(null, Typeface.NORMAL); text.setText(getString(R.string.fetch_status)); final TextView messageText = StatusViewHolder.get().messageText; messageText.setText(getString(R.string.fetch_message)); final TextView messageLabel = StatusViewHolder.get().messageLabel; messageLabel.setVisibility(TextView.GONE); startStatusCommunication(); return true; } }); if (this.spaceData == null) { this.startAnimation(); this.startStatusCommunication(); if (notificationRegistry == null) { this.notificationRegistry = new NotificationRegistry(this.getActivity()); } this.notificationRegistry.register(); } else { this.outputStatus(this.spaceData); } }
From source file:com.example.pyrkesa.frag.ScenarioAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { LayoutInflater mInflater = (LayoutInflater) context1.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); convertView = mInflater.inflate(R.layout.scenario_list_item, null); }/* w w w . ja va 2s.com*/ pos = position; ImageView imgIcon = (ImageView) convertView.findViewById(R.id.scenario); final TextView txtTitle = (TextView) convertView.findViewById(R.id.scenario_name); ImageButton imgDelete = (ImageButton) convertView.findViewById(R.id.delete_scenario); imgIcon.setImageResource(scenarioItems.get(position).getIcon_Scenario()); txtTitle.setText(scenarioItems.get(position).getName()); imgDelete.setImageResource(scenarioItems.get(position).getIcon_Delete()); imgDelete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Toast.makeText(context1,"ggffgfg",Toast.LENGTH_LONG).show(); ModelFactory model = (ModelFactory) ModelFactory.getContext(); new AlertDialog.Builder(v.getContext()).setTitle("Supprimer " + txtTitle.getText()) .setMessage("Voulez-vous supprimer ce scnario?") .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // continue with delete new DeleteScenario().execute(txtTitle.getText().toString()); } }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // do nothing } }).setIcon(android.R.drawable.ic_dialog_alert).show(); } }); return convertView; }
From source file:id.zelory.tanipedia.activity.CuacaActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cuaca); toolbar = (Toolbar) findViewById(R.id.anim_toolbar); setSupportActionBar(toolbar);/* www . jav a 2 s . co m*/ getSupportActionBar().setDisplayHomeAsUpEnabled(true); collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); animation = AnimationUtils.loadAnimation(this, R.anim.simple_grow); drawerLayout = (DrawerLayout) findViewById(R.id.nav_drawer); setUpNavDrawer(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); 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: return true; case R.id.berita: intent = new Intent(CuacaActivity.this, BeritaActivity.class); break; case R.id.tanya: intent = new Intent(CuacaActivity.this, TanyaActivity.class); break; case R.id.harga: intent = new Intent(CuacaActivity.this, KomoditasActivity.class); break; case R.id.logout: PrefUtils.simpanString(CuacaActivity.this, "nama", null); intent = new Intent(CuacaActivity.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(CuacaActivity.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); fabButton = (FabButton) findViewById(R.id.determinate); fabButton.showProgress(true); fabButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { fabButton.showProgress(true); new DownloadData().execute(); } }); cuacaText = (TextView) findViewById(R.id.cuaca); suhu = (TextView) findViewById(R.id.suhu); minmax = (TextView) findViewById(R.id.minmax); iconCuaca = (ImageView) findViewById(R.id.icon_cuaca); kegiatan = (TextView) findViewById(R.id.kegiatan); background = (LinearLayout) findViewById(R.id.background); cuacaText.setVisibility(View.GONE); suhu.setVisibility(View.GONE); minmax.setVisibility(View.GONE); iconCuaca.setVisibility(View.GONE); kegiatan.setVisibility(View.GONE); if (checkPlayServices()) { buildGoogleApiClient(); } }
From source file:com.android.browser.GearsBaseDialog.java
/** * Utility method to set a text./*from ww w. j a va 2s . co m*/ */ void setText(View v, int rsc, CharSequence text) { if (rsc == 0) { return; } View view = v.findViewById(rsc); if (view != null) { TextView textView = (TextView) view; textView.setText(text); textView.setVisibility(View.VISIBLE); } }
From source file:com.facebook.login.DeviceAuthDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { dialog = new Dialog(getActivity(), R.style.com_facebook_auth_dialog); LayoutInflater inflater = getActivity().getLayoutInflater(); View view = inflater.inflate(R.layout.com_facebook_device_auth_dialog_fragment, null); progressBar = (ProgressBar) view.findViewById(R.id.progress_bar); confirmationCode = (TextView) view.findViewById(R.id.confirmation_code); Button cancelButton = (Button) view.findViewById(R.id.cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override/*w w w .j a v a2 s . c om*/ public void onClick(View v) { onCancel(); } }); TextView instructions = (TextView) view.findViewById(R.id.com_facebook_device_auth_instructions); instructions.setText(Html.fromHtml(getString(R.string.com_facebook_device_auth_instructions))); dialog.setContentView(view); return dialog; }
From source file:com.adamkruger.myipaddressinfo.NetworkInfoFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private TextView makeTextView(String value, int color, int horizontalPadding) { Context context = getActivity(); TextView textView = new TextView(context); textView.setText(value); textView.setLayoutParams(//from ww w.ja v a 2 s .co m new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); textView.setTextAppearance(context, android.R.attr.textAppearanceSmall); textView.setTextColor(color); textView.setPadding(horizontalPadding, 0, horizontalPadding, 0); textView.setSingleLine(false); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { textView.setTextIsSelectable(true); } return textView; }