android.widget.TextView.setFocusable()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(160)

本文整理了Java中android.widget.TextView.setFocusable()方法的一些代码示例,展示了TextView.setFocusable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.setFocusable()方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:setFocusable

TextView.setFocusable介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

public class ExtendedCheckBoxListView extends LinearLayout {

  private TextView mText;
  private CheckBox mCheckBox;

  public ExtendedCheckBoxListView(Context context, ExtendedCheckBox aCheckBoxifiedText) {
     super(context);
     …
     mText.setFocusable(false);
     mText.setFocusableInTouchMode(false);

     mCheckBox.setFocusable(false);
     mCheckBox.setFocusableInTouchMode(false);
    …       
  }
}

代码示例来源:origin: nickbutcher/plaid

/**
 * Work around some 'features' of TextView and URLSpans. i.e. vanilla URLSpans do not react to
 * touch so we replace them with our own {@link TouchableUrlSpan}
 * & {@link LinkTouchMovementMethod} to fix this.
 * <p/>
 * Setting a custom MovementMethod on a TextView also alters touch handling (see
 * TextView#fixFocusableAndClickableSettings) so we need to correct this.
 */
public static void setTextWithNiceLinks(TextView textView, CharSequence input) {
  textView.setText(input);
  textView.setMovementMethod(LinkTouchMovementMethod.getInstance());
  textView.setFocusable(false);
  textView.setClickable(false);
  textView.setLongClickable(false);
}

代码示例来源:origin: libgdx/libgdx

Dialog createDialog () {
  textView = createView(context);
  textView.setOnKeyListener(this);
  FrameLayout.LayoutParams textBoxLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
    FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
  textView.setLayoutParams(textBoxLayoutParams);
  textView.setFocusable(true);
  textView.setFocusableInTouchMode(true);
  textView.setImeOptions(textView.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
  final FrameLayout layout = new FrameLayout(context);
  ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
  layout.setLayoutParams(layoutParams);
  layout.addView(textView);
  layout.setOnTouchListener(this);
  dialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
  dialog.setContentView(layout);
  return dialog;
}

代码示例来源:origin: jingle1267/android-utils

/**
 * set SearchView OnClickListener
 *
 * @param v
 * @param listener
 */
public static void setSearchViewOnClickListener(View v,
                        OnClickListener listener) {
  if (v instanceof ViewGroup) {
    ViewGroup group = (ViewGroup) v;
    int count = group.getChildCount();
    for (int i = 0; i < count; i++) {
      View child = group.getChildAt(i);
      if (child instanceof LinearLayout
          || child instanceof RelativeLayout) {
        setSearchViewOnClickListener(child, listener);
      }
      if (child instanceof TextView) {
        TextView text = (TextView) child;
        text.setFocusable(false);
      }
      child.setOnClickListener(listener);
    }
  }
}

代码示例来源:origin: libgdx/libgdx

Dialog createDialog () {
  textView = createView(context);
  textView.setOnKeyListener(this);
  FrameLayout.LayoutParams textBoxLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
    FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
  textView.setLayoutParams(textBoxLayoutParams);
  textView.setFocusable(true);
  textView.setFocusableInTouchMode(true);
  textView.setImeOptions(textView.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
  final FrameLayout layout = new FrameLayout(context);
  ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
  layout.setLayoutParams(layoutParams);
  layout.addView(textView);
  layout.setOnTouchListener(this);
  dialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
  dialog.setContentView(layout);
  return dialog;
}

代码示例来源:origin: stackoverflow.com

void setLinks(TextView tv, String text) {
   String[] linkPatterns = {
       "([Hh][tT][tT][pP][sS]?:\\/\\/[^ ,'\">\\]\\)]*[^\\. ,'\">\\]\\)])",
       "#[\\w]+", "@[\\w]+" };
   for (String str : linkPatterns) {
     Pattern pattern = Pattern.compile(str);
     Matcher matcher = pattern.matcher(tv.getText());
     while (matcher.find()) {
       int x = matcher.start();
       int y = matcher.end();
       final android.text.SpannableString f = new android.text.SpannableString(
           tv.getText());
       InternalURLSpan span = new InternalURLSpan();
       span.text = text.substring(x, y);
       f.setSpan(span, x, y,
           android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
       tv.setText(f);
       // tv.setOnLongClickListener(span.l);
     }
   }
   tv.setLinkTextColor(Color.BLUE);
   tv.setLinksClickable(true);
   tv.setMovementMethod(LinkMovementMethod.getInstance());
   tv.setFocusable(false);
 }

代码示例来源:origin: stackoverflow.com

textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.START);
textView.setClickable(false);
textView.setFocusable(false);
textView.setFocusableInTouchMode(false);
textView.setTextColor(android.graphics.Color.WHITE);

代码示例来源:origin: hejunlin2013/EpisodeListView

public MyViewHolder(View view) {
    super(view);
    textView = (TextView) view.findViewById(R.id.item);
    textView.setFocusable(true);
  }
}

代码示例来源:origin: amahi/android

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
  mContext = parent.getContext();
  TextView view = new TextView(mContext);
  view.setLayoutParams(new ViewGroup.LayoutParams(SETTINGS_ITEM_WIDTH, SETTINGS_ITEM_HEIGHT));
  view.setFocusable(true);
  view.setFocusableInTouchMode(true);
  view.setBackgroundColor(Color.DKGRAY);
  view.setTextColor(Color.WHITE);
  view.setGravity(Gravity.CENTER);
  return new ViewHolder(view);
}

代码示例来源:origin: SiberiaDante/TitleLayout

/**
 * 设置左侧文字是否可以点击
 */
public void setLeftTextClickable(boolean isClickable) {
  mTvLeft.setClickable(isClickable);
  mTvLeft.setFocusable(isClickable);
}

代码示例来源:origin: Tamicer/TvFrameWork

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
  TextView view = new TextView(parent.getContext());
  view.setLayoutParams(new ViewGroup.LayoutParams(GRID_ITEM_WIDTH, GRID_ITEM_HEIGHT));
  view.setFocusable(true);
  view.setFocusableInTouchMode(true);
  view.setBackgroundColor(getResources().getColor(R.color.default_background));
  view.setTextColor(Color.WHITE);
  view.setGravity(Gravity.CENTER);
  return new ViewHolder(view);
}

代码示例来源:origin: SiberiaDante/TitleLayout

/**
 * 设置右侧文字是否可以点击
 */
public void setRightTextClickable(boolean isClickable) {
  mTvRight.setClickable(isClickable);
  mTvRight.setFocusable(isClickable);
}

代码示例来源:origin: stackoverflow.com

// make the title scroll!
    // find the title TextView
    TextView title = (TextView) findViewById(android.R.id.title);
    // set the ellipsize mode to MARQUEE and make it scroll only once
    title.setEllipsize(TruncateAt.MARQUEE);
    title.setMarqueeRepeatLimit(1);
    // in order to start strolling, it has to be focusable and focused
    title.setFocusable(true);
    title.setFocusableInTouchMode(true);
    title.requestFocus();

代码示例来源:origin: stackoverflow.com

TextView text2 = (TextView) findViewById(R.id.textView1);
 Button button2 = (Button) findViewById(R.id.button2);
 button2.setOnClickListener(new OnClickListener(){
   public void onClick(View v) {
     text2.setFocusable(true);
     text2.requestFocus(); 
   }
 });

代码示例来源:origin: stackoverflow.com

// make the title scroll!
// find the title TextView

TextView title = (TextView) findViewById(android.R.id.title);
// set the ellipsize mode to MARQUEE and make it scroll only once
title.setEllipsize(TruncateAt.MARQUEE);
title.setMarqueeRepeatLimit(1);
// in order to start strolling, it has to be focusable and focused
title.setFocusable(true);
title.setFocusableInTouchMode(true);
title.requestFocus();

代码示例来源:origin: JinBoy23520/CoderToDeveloperByTCLer

/**
 * 倒计时
 */
private void doCountdown() {
  countdownNum = COUNT_MAX;
  txtSendCode.setEnabled(false);
  txtSendCode.setFocusable(false);
  timer.start();
}
@Override

代码示例来源:origin: stackoverflow.com

TextView textView=(TextView)findViewById(R.id.text_test);
 textView .setEllipsize(TextUtils.TruncateAt.MARQUEE);
 textView .setSingleLine(true);
 textView .setMarqueeRepeatLimit(-1);
 textView.setFocusableInTouchMode(true);
 textView.setFocusable(true);

代码示例来源:origin: lucid-lynxz/BlogSamples

private void initView() {
  TextView tvMain = findView(R.id.tv_main);
  tvMain.setFocusable(false);
  // 将随机获得的图像追加到EditText控件的最后
  tvMain.append(parseHtml());
  tvMain.append(" 测试文本 ");
  tvMain.append(parseHtml());
  tvMain.append(" 这表情还不错吧? ");
  tvMain.append(parseHtml());
  tvMain.append(" 随机添加表情 ");
  tvMain.append(parseHtml());
}

代码示例来源:origin: delight-im/Android-Commons

/**
 * Sets the given `TextView` to be read-only or read-and-write
 *
 * @param view a `TextView` or one of its subclasses
 * @param readOnly whether the view should be read-only or not
 */
public static void setReadOnly(final TextView view, final boolean readOnly) {
  view.setFocusable(!readOnly);
  view.setFocusableInTouchMode(!readOnly);
  view.setClickable(!readOnly);
  view.setLongClickable(!readOnly);
  view.setCursorVisible(!readOnly);
}

代码示例来源:origin: stackoverflow.com

this.setTitle("my title!");
((TextView)v.findViewById(R.id.title)).setText(this.getTitle());
TextView title = ((TextView)v.findViewById(R.id.title));
title.setEllipsize(TextUtils.TruncateAt.MARQUEE);
title.setMarqueeRepeatLimit(1);
// in order to start strolling, it has to be focusable and focused
title.setFocusable(true);
title.setSingleLine(true);
title.setFocusableInTouchMode(true);
title.requestFocus();

相关文章

TextView类方法