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

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

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

TextView.setOnClickListener介绍

暂无

代码示例

代码示例来源:origin: gabrielemariotti/RecyclerViewItemAnimators

@Override
public void onBindViewHolder(SimpleViewHolder holder, final int position) {
  holder.title.setText(mData.get(position));
  holder.title.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
      Toast.makeText(mContext, "Position =" + position, Toast.LENGTH_SHORT).show();
    }
  });
}

代码示例来源:origin: TeamNewPipe/NewPipe

private void buildSeekBar() {
  progressCurrentTime = rootView.findViewById(R.id.current_time);
  progressSeekBar = rootView.findViewById(R.id.seek_bar);
  progressEndTime = rootView.findViewById(R.id.end_time);
  progressLiveSync = rootView.findViewById(R.id.live_sync);
  seekDisplay = rootView.findViewById(R.id.seek_display);
  progressSeekBar.setOnSeekBarChangeListener(this);
  progressLiveSync.setOnClickListener(this);
}

代码示例来源:origin: TommyLemon/APIJSON

@SuppressLint("InflateParams")
@Override
public View getLeftMenu(Activity activity) {
  if (leftMenu == null) {
    leftMenu = (TextView) LayoutInflater.from(activity).inflate(R.layout.top_right_tv, null);
    leftMenu.setGravity(Gravity.CENTER);
    leftMenu.setText("扫一扫");
    leftMenu.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        onDragBottom(false);
      }
    });
  }
  return leftMenu;
}

代码示例来源:origin: andkulikov/Transitions-Everywhere

@Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_change_text, container, false);

    final ViewGroup transitionsContainer = view.findViewById(R.id.transitions_container);
    final TextView textView = transitionsContainer.findViewById(R.id.text1);

    textView.setText(TEXT_1);
    textView.setOnClickListener(new View.OnClickListener() {

      boolean mSecondText;

      @Override
      public void onClick(View v) {
        mSecondText = !mSecondText;
        TransitionManager.beginDelayedTransition(transitionsContainer,
          new ChangeText().setChangeBehavior(ChangeText.CHANGE_BEHAVIOR_OUT_IN));
        textView.setText(mSecondText ? TEXT_2 : TEXT_1);
      }

    });

    return view;
  }
}

代码示例来源:origin: aa112901/remusic

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
             Bundle savedInstanceState) {
  //设置无标题
  getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
  View view = inflater.inflate(R.layout.fragment_timing, container);
  timing10 = (TextView) view.findViewById(R.id.timing_10min);
  timing20 = (TextView) view.findViewById(R.id.timing_20min);
  timing30 = (TextView) view.findViewById(R.id.timing_30min);
  timing45 = (TextView) view.findViewById(R.id.timing_45min);
  timing60 = (TextView) view.findViewById(R.id.timing_60min);
  timing90 = (TextView) view.findViewById(R.id.timing_90min);
  timing10.setOnClickListener(this);
  timing20.setOnClickListener(this);
  timing30.setOnClickListener(this);
  timing45.setOnClickListener(this);
  timing60.setOnClickListener(this);
  timing90.setOnClickListener(this);
  return view;
}

代码示例来源:origin: yarolegovich/SlidingRootNav

@Override
  public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    final String text = getArguments().getString(EXTRA_TEXT);
    TextView textView = view.findViewById(R.id.text);
    textView.setText(text);
    textView.setOnClickListener(new View.OnClickListener() {
      @Override public void onClick(View v) {
        Toast.makeText(v.getContext(), text, Toast.LENGTH_SHORT).show();
      }
    });
  }
}

代码示例来源:origin: TommyLemon/APIJSON

tvTab.setTextSize(18);
tvTab.setSingleLine(true);
tvTab.setText(name);
tvTab.setOnClickListener(new OnClickListener() {
  @Override
  public void onClick(View v) {

代码示例来源:origin: jaydenxiao2016/AndroidFire

/**
 * 初始化viwe
 */
private void findViews() {
  LayoutInflater inflater = (LayoutInflater) getContext()
      .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  inflater.inflate(R.layout.item_expand_shink, this);
  mTvContent = (TextView) findViewById(R.id.expandable_text);
  mTvContent.setOnClickListener(this);
  mTvExpandCollapse = (TextView) findViewById(R.id.expand_collapse);
  if(showExpandCollapseDrawable) {
    mTvExpandCollapse.setCompoundDrawablesWithIntrinsicBounds(null, null, mCollapsed ? mExpandDrawable : mCollapseDrawable, null);
  }
  mTvExpandCollapse.setText(mCollapsed ? getResources().getString(R.string.expand) : getResources().getString(R.string.shink));
  mTvExpandCollapse.setOnClickListener(this);
  mTvContent.setTextColor(contentTextColor);
  mTvContent.getPaint().setTextSize(contentTextSize);
  mTvExpandCollapse.setTextColor(collapseExpandTextColor);
  mTvExpandCollapse.getPaint().setTextSize(collapseExpandTextSize);
  //设置收起展开位置:左或者右
  LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
  lp.gravity = grarity;
  mTvExpandCollapse.setLayoutParams(lp);
}
/**

代码示例来源:origin: dongjunkun/DropDownMenu

final View constellationView = getLayoutInflater().inflate(R.layout.custom_layout, null);
GridView constellation = ButterKnife.findById(constellationView, R.id.constellation);
constellationAdapter = new ConstellationAdapter(this, Arrays.asList(constellations));
constellation.setAdapter(constellationAdapter);
TextView ok = ButterKnife.findById(constellationView, R.id.ok);
ok.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
contentView.setText("内容显示区域");
contentView.setGravity(Gravity.CENTER);
contentView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);

代码示例来源:origin: iSoron/uhabits

getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
View view = inflater.inflate(R.layout.time_picker_dialog, null);
KeyboardListener keyboardListener = new KeyboardListener();
view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener);
mUnselectedColor = res.getColor(mThemeDark? R.color.white : R.color.numbers_text_color);
mTimePicker.invalidate();
mHourView.setOnClickListener(new OnClickListener() {
  @Override
  public void onClick(View v) {
mMinuteView.setOnClickListener(new OnClickListener() {
  @Override
  public void onClick(View v) {
mDoneButton = (TextView) view.findViewById(R.id.done_button);
mDoneButton.setOnClickListener(new OnClickListener() {
  @Override
  public void onClick(View v) {
mClearButton = (TextView) view.findViewById(R.id.clear_button);
mClearButton.setOnClickListener(new OnClickListener()

代码示例来源:origin: EverythingMe/overscroll-decor

public DemoViewHolder(int resId, ViewGroup parent, LayoutInflater inflater) {
  mTextView = (TextView) inflater.inflate(resId, parent, false);
  mTextView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      Toast.makeText(mTextView.getContext(), "Tapped on: "+mTextView.getText(), Toast.LENGTH_SHORT).show();
    }
  });
  mTextView.setOnLongClickListener(new View.OnLongClickListener() {
    @Override
    public boolean onLongClick(View v) {
      Toast.makeText(mTextView.getContext(), "Long-tapped on: "+mTextView.getText(), Toast.LENGTH_SHORT).show();
      return false;
    }
  });
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public Object instantiateItem(ViewGroup container, int position) {
 View page=
   getLayoutInflater().inflate(R.layout.page, container, false);
 TextView tv=page.findViewById(R.id.text);
 int blue=position * 25;
 final String msg=
   String.format(getString(R.string.item), position + 1);
 tv.setText(msg);
 tv.setOnClickListener(new OnClickListener() {
  @Override
  public void onClick(View v) {
   Toast.makeText(MainActivity.this, msg, Toast.LENGTH_LONG)
      .show();
  }
 });
 page.setBackgroundColor(Color.argb(255, 0, 0, blue));
 container.addView(page);
 return(page);
}

代码示例来源:origin: Rukey7/MvpApp

private void _initLoadingView() {
  if (mLoadingView == null) {
    mLoadingView = mLayoutInflater.inflate(R.layout.layout_load_more, null);
    mLoadingView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.WRAP_CONTENT));
    mLoadingDesc = (TextView) mLoadingView.findViewById(R.id.tv_loading_desc);
    mLoadingIcon = (SpinKitView) mLoadingView.findViewById(R.id.iv_loading_icon);
    mLoadingStr = mContext.getResources().getString(R.string.loading_desc);
    mLoadingDesc.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        if (!mIsLoadingNow && !mIsNoMoreData) {
          _loadMore();
        }
      }
    });
  }
}

代码示例来源:origin: TommyLemon/APIJSON

@SuppressLint("InflateParams")
@Override
public View getRightMenu(Activity activity) {
  if (rightMenu == null) {
    rightMenu = (TextView) LayoutInflater.from(activity).inflate(R.layout.top_right_tv, null);
    rightMenu.setGravity(Gravity.CENTER);
    rightMenu.setText("设置");
    rightMenu.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        onDragBottom(true);
      }
    });
  }
  return rightMenu;
}

代码示例来源:origin: hidroh/materialistic

protected void clear(VH holder) {
  holder.mCommentButton.setVisibility(View.GONE);
  holder.mPostedTextView.setOnClickListener(null);
  holder.mPostedTextView.setText(R.string.loading_text);
  holder.mContentTextView.setText(R.string.loading_text);
  holder.mReadMoreTextView.setVisibility(View.GONE);
}

代码示例来源:origin: TeamNewPipe/NewPipe

private void setupStepSizeSelector(@NonNull final View rootView) {
  TextView stepSizeOnePercentText = rootView.findViewById(R.id.stepSizeOnePercent);
  TextView stepSizeFivePercentText = rootView.findViewById(R.id.stepSizeFivePercent);
  TextView stepSizeTenPercentText = rootView.findViewById(R.id.stepSizeTenPercent);
  TextView stepSizeTwentyFivePercentText = rootView.findViewById(R.id.stepSizeTwentyFivePercent);
  TextView stepSizeOneHundredPercentText = rootView.findViewById(R.id.stepSizeOneHundredPercent);
    stepSizeOnePercentText.setText(getPercentString(STEP_ONE_PERCENT_VALUE));
    stepSizeOnePercentText.setOnClickListener(view ->
        changeStepSize(STEP_ONE_PERCENT_VALUE));
    stepSizeFivePercentText.setText(getPercentString(STEP_FIVE_PERCENT_VALUE));
    stepSizeFivePercentText.setOnClickListener(view ->
        changeStepSize(STEP_FIVE_PERCENT_VALUE));
    stepSizeTenPercentText.setText(getPercentString(STEP_TEN_PERCENT_VALUE));
    stepSizeTenPercentText.setOnClickListener(view ->
        changeStepSize(STEP_TEN_PERCENT_VALUE));
    stepSizeTwentyFivePercentText.setText(getPercentString(STEP_TWENTY_FIVE_PERCENT_VALUE));
    stepSizeTwentyFivePercentText.setOnClickListener(view ->
        changeStepSize(STEP_TWENTY_FIVE_PERCENT_VALUE));
    stepSizeOneHundredPercentText.setText(getPercentString(STEP_ONE_HUNDRED_PERCENT_VALUE));
    stepSizeOneHundredPercentText.setOnClickListener(view ->
        changeStepSize(STEP_ONE_HUNDRED_PERCENT_VALUE));

代码示例来源:origin: GitLqr/LQRWeChat

tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
tvAt.setGravity(Gravity.BOTTOM);
tvAt.setText("@");
int padding = (int) (DESIGN_LEFT_PADDING * ratio);
tvAt.setPadding(padding, 0, padding, 0);
lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
llAt.addView(tvAt, lp);
tvAt.setOnClickListener(this);
if (isShowAtUserLayout(platform.getName())) {
  tvAt.setVisibility(View.VISIBLE);

代码示例来源:origin: iMeiji/Toutiao

.subscribe(list -> {
  for (int i = 0; i < list.size(); i++) {
    final TextView tv = (TextView) LayoutInflater.from(SearchActivity.this).inflate(R.layout.item_search_sug_text, flexboxLayout, false);
    final String keyWord = list.get(i);
    int color = Constant.TAG_COLORS[i % Constant.TAG_COLORS.length];
    tv.setText(keyWord);
    tv.setBackgroundColor(color);
    tv.setTextColor(Color.WHITE);
    tv.setOnClickListener(view -> {
      searchView.clearFocus();
      searchView.setQuery(keyWord, true);

代码示例来源:origin: TeamNewPipe/NewPipe

private void buildControls() {
  repeatButton = rootView.findViewById(R.id.control_repeat);
  backwardButton = rootView.findViewById(R.id.control_backward);
  playPauseButton = rootView.findViewById(R.id.control_play_pause);
  forwardButton = rootView.findViewById(R.id.control_forward);
  shuffleButton = rootView.findViewById(R.id.control_shuffle);
  playbackSpeedButton = rootView.findViewById(R.id.control_playback_speed);
  playbackPitchButton = rootView.findViewById(R.id.control_playback_pitch);
  progressBar = rootView.findViewById(R.id.control_progress_bar);
  repeatButton.setOnClickListener(this);
  backwardButton.setOnClickListener(this);
  playPauseButton.setOnClickListener(this);
  forwardButton.setOnClickListener(this);
  shuffleButton.setOnClickListener(this);
  playbackSpeedButton.setOnClickListener(this);
  playbackPitchButton.setOnClickListener(this);
}

代码示例来源:origin: aa112901/remusic

private void loadAllLists() {
  tryAgain.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      loadAllLists();
    }
  });
  if (NetworkUtils.isConnectInternet(this)) {
    tryAgain.setVisibility(View.GONE);
    loadView = LayoutInflater.from(this).inflate(R.layout.loading, loadFrameLayout, false);
    loadFrameLayout.addView(loadView);
    mLoadNetList = new LoadNetPlaylistInfo();
    mLoadNetList.execute();
  } else {
    tryAgain.setVisibility(View.VISIBLE);
  }
}

相关文章

TextView类方法