// text2 has links specified by putting <a> tags in the string // resource. By default these links will appear but not // respond to user input. To make them active, you need to // call setMovementMethod() on the TextView object. TextView t2 = (TextView) findViewById(R.id.text2); t2.setMovementMethod(LinkMovementMethod.getInstance());
EditText et = (EditText)findViewById(R.id.inbox); et.setSelection(et.getText().length());
TextView tv = (TextView)findViewById(R.id.my_text_view); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)tv.getLayoutParams(); params.setMargins(0, 0, 10, 0); //substitute parameters for left, top, right, bottom tv.setLayoutParams(params);
TextView txt = (TextView) findViewById(R.id.output); txt.setText("Executed");
EditText usernameEditText = (EditText) findViewById(R.id.editUsername); sUsername = usernameEditText.getText().toString(); if (sUsername.matches("")) { Toast.makeText(this, "You did not enter a username", Toast.LENGTH_SHORT).show(); return; }
protected FrameLayout.LayoutParams createLayoutParams () { FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT); layoutParams.gravity = Gravity.CENTER; return layoutParams; }
/** * Sets the given {@link android.graphics.drawable.Drawable} on the view using {@link * android.widget.ImageView#setImageDrawable(android.graphics.drawable.Drawable)}. * * @param drawable {@inheritDoc} */ @Override public void setDrawable(Drawable drawable) { view.setImageDrawable(drawable); }
/** * Sets the {@link android.graphics.Bitmap} on the view using {@link * android.widget.ImageView#setImageBitmap(android.graphics.Bitmap)}. * * @param resource The bitmap to display. */ @Override protected void setResource(Bitmap resource) { view.setImageBitmap(resource); } }
EditText editor = new EditText(this); editor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
TextView tv = (TextView)findViewById(R.id.image_test); LayerDrawable ld = (LayerDrawable)tv.getBackground(); int topInset = tv.getHeight() / 2 ; //does not work! ld.setLayerInset(1, 0, topInset, 0, 0); tv.setBackgroundDrawable(ld);
final TextView tv = (TextView)findViewById(R.id.image_test); ViewTreeObserver vto = tv.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { LayerDrawable ld = (LayerDrawable)tv.getBackground(); ld.setLayerInset(1, 0, tv.getHeight() / 2, 0, 0); } });
Spinner spinner = (Spinner)findViewById(R.id.spinner); String text = spinner.getSelectedItem().toString();
TextView textView = (TextView) findViewById(R.id.myTxtView); textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon, 0, 0, 0);
protected FrameLayout.LayoutParams createLayoutParams () { FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT); layoutParams.gravity = Gravity.CENTER; return layoutParams; }
@Override protected void setResource(Drawable resource) { this.resource = resource; view.setImageDrawable(resource); } }
protected FrameLayout.LayoutParams createLayoutParams () { FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT); layoutParams.gravity = Gravity.CENTER; return layoutParams; }
protected FrameLayout.LayoutParams createLayoutParams () { FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT); layoutParams.gravity = Gravity.CENTER; return layoutParams; }
protected FrameLayout.LayoutParams createLayoutParams () { FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT); layoutParams.gravity = Gravity.CENTER; return layoutParams; }
protected FrameLayout.LayoutParams createLayoutParams () { FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT); layoutParams.gravity = Gravity.CENTER; return layoutParams; }