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

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

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

TextView.setOnFocusChangeListener介绍

暂无

代码示例

代码示例来源:origin: xiangzhihong/gpuImage

/**
 * edittext获得焦点
 * @param context
 */
public static void getFocus(TextView tv, final Activity context) {
  tv.setOnFocusChangeListener(new View.OnFocusChangeListener() {
    @Override
    public void onFocusChange(View v, boolean hasFocus) {
      if (hasFocus) {
        context.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
      }
    }
  });
}

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

private void setOnFocusChangeListener(TextView textView, String name){

  textView.setOnFocusChangeListener(new OnFocusChangeListener() {          
    public void onFocusChange(View v, boolean hasFocus) {
      if(!hasFocus) {
        saveThisItem(txtClientID.getText(), name, 
               textView.getText());
      }
    }
  });
}

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

TextView mTextView = new TextView(this);
mTextView.setOnFocusChangeListener(new OnFocusChangeListener(){

  @Override
  public void onFocusChange(View arg0, boolean arg1) {
    // Add your code for the focus change of the textview

  }

});

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

@Override
public void onBindViewHolder(MyViewHolder holder, final int position) {
  holder.textView.setText(mDatas.get(position));
  holder.textView.setWidth(itemWidth);
  holder.textView.setFocusable(true);
  holder.textView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      mItemClickListener.onGroupItemClick(v, position);
    }
  });
  holder.textView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
    @Override
    public void onFocusChange(View v, boolean hasFocus) {
      if (hasFocus) {
        mItemFocusListener.onGroupItemFocus(v, position, hasFocus);
        mCurrentPosition = position;
      }
    }
  });
}

代码示例来源:origin: ImangazalievM/ReActiveAndroid

public NewFolderViewHolder(FoldersEditAdapter adapter, View itemView) {
  super(itemView);
  this.adapter = adapter;
  this.leftButton = itemView.findViewById(R.id.left_button);
  this.folderName = itemView.findViewById(R.id.folder_name_text);
  this.doneButton = itemView.findViewById(R.id.done_button);
  this.focusHolder = itemView.findViewById(R.id.focus_holder);
  folderName.setOnFocusChangeListener((v, hasFocus) -> {
    if (hasFocus) {
      open();
    }
  });
  folderName.setOnEditorActionListener((v, actionId, event) -> {
    if (actionId == EditorInfo.IME_ACTION_DONE) {
      onDoneButtonClick();
      return true;
    }
    return false;
  });
  leftButton.setOnClickListener(view -> onLeftButtonClick());
  doneButton.setOnClickListener(view -> onDoneButtonClick());
}

代码示例来源:origin: ImangazalievM/ReActiveAndroid

public EditFolderViewHolder(FoldersEditAdapter adapter, View itemView) {
  super(itemView);
  this.adapter = adapter;
  this.leftButton = itemView.findViewById(R.id.left_button);
  this.folderName = itemView.findViewById(R.id.folder_name_text);
  this.rightButton = itemView.findViewById(R.id.right_button);
  this.folderNameInputLayout = itemView.findViewById(R.id.folder_name_input_layout);
  this.focusHolder = itemView.findViewById(R.id.focus_holder);
  folderName.setOnFocusChangeListener((v, hasFocus) -> {
    if (hasFocus) {
      open();
    }
  });
  folderName.setOnEditorActionListener((v, actionId, event) -> {
    if (actionId == EditorInfo.IME_ACTION_DONE) {
      apply();
      close();
      return true;
    }
    return false;
  });
  leftButton.setOnClickListener(view -> onLeftButtonClick());
  rightButton.setOnClickListener(view -> onRightButtonClick());
}

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

holder.textView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
  @Override
  public void onFocusChange(final View v, boolean hasFocus) {

代码示例来源:origin: fookwood/Launcher3

void resetLayout() {
  mContent.removeAllViewsInLayout();
  // Add the Apps button
  Context context = getContext();
  LayoutInflater inflater = LayoutInflater.from(context);
  TextView allAppsButton = (TextView)
      inflater.inflate(R.layout.all_apps_button, mContent, false);
  Drawable d = context.getResources().getDrawable(R.drawable.all_apps_button_icon);
  mLauncher.resizeIconDrawable(d);
  allAppsButton.setCompoundDrawables(null, d, null, null);
  allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
  allAppsButton.setOnKeyListener(new HotseatIconKeyEventListener());
  if (mLauncher != null) {
    mLauncher.setAllAppsButton(allAppsButton);
    allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
    allAppsButton.setOnClickListener(mLauncher);
    allAppsButton.setOnLongClickListener(mLauncher);
    allAppsButton.setOnFocusChangeListener(mLauncher.mFocusHandler);
  }
  // Note: We do this to ensure that the hotseat is always laid out in the orientation of
  // the hotseat in order regardless of which orientation they were added
  int x = getCellXFromOrder(mAllAppsButtonRank);
  int y = getCellYFromOrder(mAllAppsButtonRank);
  CellLayout.LayoutParams lp = new CellLayout.LayoutParams(x,y,1,1);
  lp.canReorder = false;
  mContent.addViewToCellLayout(allAppsButton, -1, allAppsButton.getId(), lp, true);
}

代码示例来源:origin: AriesHoo/UIWidget

mTvTitleSub.setFocusableInTouchMode(true);
mTvTitleSub.requestFocus();
mTvTitleSub.setOnFocusChangeListener(new View.OnFocusChangeListener() {
  @Override
  public void onFocusChange(View v, boolean hasFocus) {
mTvTitleSub.setMaxLines(1);
mTvTitleSub.setEllipsize(TextUtils.TruncateAt.END);
mTvTitleSub.setOnFocusChangeListener(null);

代码示例来源:origin: AriesHoo/UIWidget

public TitleBarView setTitleMainTextMarquee(boolean enable) {
  this.mTitleMainTextMarquee = enable;
  if (enable) {
    setTitleSubTextMarquee(false);
    mTvTitleMain.setSingleLine();
    mTvTitleMain.setEllipsize(TextUtils.TruncateAt.MARQUEE);
    mTvTitleMain.setFocusable(true);
    mTvTitleMain.setFocusableInTouchMode(true);
    mTvTitleMain.requestFocus();
    mTvTitleMain.setOnFocusChangeListener(new View.OnFocusChangeListener() {
      @Override
      public void onFocusChange(View v, boolean hasFocus) {
        if (!hasFocus && mTitleMainTextMarquee) {
          mTvTitleMain.requestFocus();
        }
      }
    });
    //开启硬件加速
    mTvTitleMain.setLayerType(View.LAYER_TYPE_HARDWARE, null);
  } else {
    mTvTitleMain.setMaxLines(1);
    mTvTitleMain.setEllipsize(TextUtils.TruncateAt.END);
    mTvTitleMain.setOnFocusChangeListener(null);
    //关闭硬件加速
    mTvTitleMain.setLayerType(View.LAYER_TYPE_NONE, null);
  }
  return this;
}

代码示例来源:origin: ShuKeW/TVRecyclerViewAndFocus

tab.setTag(R.id.focus_type_is_translate, true);
tab.setTag(R.id.focus_type_is_scale_anim, true);
tab.setOnFocusChangeListener(new View.OnFocusChangeListener() {

相关文章

微信公众号

最新文章

更多

TextView类方法