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

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

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

TextView.setFocusableInTouchMode介绍

暂无

代码示例

代码示例来源: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: 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: 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

textView.setClickable(false);
textView.setFocusable(false);
textView.setFocusableInTouchMode(false);
textView.setTextColor(android.graphics.Color.WHITE);

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

// Get the first component and make sure it is focusable. Note you have to use setFocusableInTouchMode and not setFocusable for this to work.
TextView v = (TextView) view.findViewById(R.id.first_component_in_view);
v.setFocusableInTouchMode(true);
v.requestFocus();

代码示例来源: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: 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: bitcraze/crazyflie-android-client

@Override
protected View onCreateDialogView() {
  LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
  LinearLayout layout = new LinearLayout(getContext());
  layout.setOrientation(LinearLayout.VERTICAL);
  layout.setPadding(6,6,6,6);
  TextView promptTextView = new TextView(getContext());
  promptTextView.setText(R.string.preferences_axis_mapping_dialog_text);
  promptTextView.setGravity(Gravity.CENTER_HORIZONTAL);
  mValueTextView = new TextView(getContext());
  mValueTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
  mValueTextView.setGravity(Gravity.CENTER_HORIZONTAL);
  mValueTextView.setPadding(0, 12, 0, 12);
  mValueTextView.setOnGenericMotionListener(this);
  //TODO: is there an easier way to make this work?
  //motion events are not captured when view is not focusable
  mValueTextView.setFocusableInTouchMode(true);
  //if focus is not set, right analog stick events are only recognized after the left analog stick is moved!?!
  mValueTextView.requestFocus();
  layout.addView(promptTextView, params);
  layout.addView(mValueTextView, params);
  return layout;
}

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

TextView txt = new TextView(this);     
txt.setText(“This is moving text”);      
txt.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);     
txt.setTextColor(Color.rgb(187, 88, 15));     
txt.setPadding(10, 10, 0, 0);     
txt.setEllipsize(TruncateAt.MARQUEE);     
txt.setSingleLine();     
txt.setMarqueeRepeatLimit(10);     
txt.setFocusable(true);     
txt.setHorizontallyScrolling(true);     
txt.setFocusableInTouchMode(true);     
txt.requestFocus();     
txt.setLayoutParams(new TableRow.LayoutParams(130, TableRow.LayoutParams.FILL_PARENT));
txt.setTypeface(Typeface.SERIF,Typeface.BOLD);

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

TextView txt = new TextView(this);     
txt.setText(“This is moving text”);      
txt.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);     
txt.setTextColor(Color.rgb(187, 88, 15));     
txt.setPadding(10, 10, 0, 0);     
txt.setEllipsize(TruncateAt.MARQUEE);     
txt.setSingleLine();     
txt.setMarqueeRepeatLimit(10);     
txt.setFocusable(true);     
txt.setHorizontallyScrolling(true);     
txt.setFocusableInTouchMode(true);     
txt.requestFocus();     
txt.setLayoutParams(new TableRow.LayoutParams(130, TableRow.LayoutParams.FILL_PARENT));
txt.setTypeface(Typeface.SERIF,Typeface.BOLD);

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

TextView tv = new TextView(this);
 rl.addView(tv);// Here is Your Mistake ! Remove it 
 tv.setLayoutParams(paramsSong);     
 tv.setEllipsize(TruncateAt.MARQUEE);
 tv.setFocusableInTouchMode(true);
 tv.setFreezesText(true);
 tv.setSingleLine(true);
 tv.setMarqueeRepeatLimit(-1);
 tv.setText("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
 tv.setSelected(true);
     rl.addView(tv);// Adding view Here is Absolutely Right ! 
 DigitalClock dg = new DigitalClock(this);
 dg.setHeight(setHeightHere);
 dg.setWidth(setWidthHere);
     rl.addView(dg);

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

TextView titleTextView = null;
 try {
   Field f = toolbar.getClass().getDeclaredField("mTitleTextView");
   f.setAccessible(true);
   titleTextView = (TextView) f.get(toolbar);
   titleTextView.setEllipsize(TruncateAt.MARQUEE);
   titleTextView.setFocusable(true);
   titleTextView.setFocusableInTouchMode(true);
   titleTextView.requestFocus();
   titleTextView.setSingleLine(true);
   titleTextView.setSelected(true);
   titleTextView.setMarqueeRepeatLimit(-1);
 } catch (NoSuchFieldException e) {
 } catch (IllegalAccessException e) {
 }

代码示例来源: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: andstatus/andstatus

public static void showSpannable(TextView textView, @NonNull Spannable spannable, boolean showIfEmpty) {
  if (textView == null) return;
  if (spannable.length() == 0) {
    textView.setText("");
    ViewUtils.showView(textView, showIfEmpty);
  } else {
    textView.setText(spannable);
    if (hasSpans(spannable)) {
      textView.setFocusable(true);
      textView.setFocusableInTouchMode(true);
      textView.setLinksClickable(true);
      setOnTouchListener(textView);
    }
    ViewUtils.showView(textView, true);
  }
}

代码示例来源: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

// 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: 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: huangweicai/OkLibDemo

private TextView createCenterTitle() {
  TextView centerTitleTv = new TextView(getContext());
  centerTitleTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
  centerTitleTv.setTextColor(getResources().getColor(R.color.oklib_frame_black));
  LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);
  params.gravity = Gravity.CENTER;//layout_gravity
  centerTitleTv.setLayoutParams(params);
  //单行并长度显示处理
  centerTitleTv.setFocusable(true);
  centerTitleTv.setFocusableInTouchMode(true);
  centerTitleTv.setSingleLine();
  centerTitleTv.setEllipsize(TextUtils.TruncateAt.END);
  //控制最大长度
  centerTitleTv.setMaxWidth(getScreenWidth(getContext()) - dp2px(getContext(), 130));
  return centerTitleTv;
}

代码示例来源: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();

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

int titleId = Resources.getSystem().
     getIdentifier("action_bar_title", "id", "android");
     if(titleId==0)
      titleId=com.actionbarsherlock.R.id.abs__action_bar_title;
      TextView mApptitle=(TextView)findViewById(titleId);
      mApptitle.setEllipsize(TruncateAt.MARQUEE);
       mApptitle.setMarqueeRepeatLimit(1);
       mApptitle.setFocusable(true);
       mApptitle.setFocusableInTouchMode(true);
       mApptitle.requestFocus();
       mApptitle.setSingleLine(true);
       mApptitle.setSelected(true);
       mApptitle.setMarqueeRepeatLimit(-1);

相关文章

TextView类方法