android.widget.Button.setTag()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(180)

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

Button.setTag介绍

暂无

代码示例

代码示例来源:origin: lingochamp/FileDownloader

@Override
  public void onClick(View v) {
    final boolean toStart = (boolean) actionBtn.getTag();
    if (toStart) {
      if (start()) {
        actionBtn.setText(R.string.pause);
        actionBtn.setTag(false);
      }
    } else {
      actionBtn.setText(R.string.start);
      pause();
      actionBtn.setTag(true);
    }
  }
});

代码示例来源:origin: rey5137/material

private void onEndDateChanged(long date){
  mEndDateButton.setTag(date);
  mEndDateButton.setText(mDateFormat.format(new Date(date)));
  mRecurring.setEndDate(date);
}

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

@Override
 public View getView(int position, View convertView, ViewGroup parent) 
 {
   View row = null;
   LayoutInflater inflater = getLayoutInflater();
   row = inflater.inflate(R.layout.one_result_details_row, parent, false);
   // inflate other items here : 
   Button deleteButton = (Button) row.findViewById(R.id.Details_Button01);
    deleteButton.setTag(position);
   deleteButton.setOnClickListener(
     new Button.OnClickListener() {
       @Override
       public void onClick(View v) {
         Integer index = (Integer) view.getTag();
         items.remove(index.intValue());  
         notifyDataSetChanged();
       }
     }
   );

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

private void addDemo(String demoName, Class<? extends Activity> activityClass) {
  Button b = new Button(this);
  ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
  b.setLayoutParams(layoutParams);
  b.setText(demoName);
  b.setTag(activityClass);
  b.setOnClickListener(this);
  mListView.addView(b);
}

代码示例来源:origin: lingochamp/FileDownloader

private void checkEndAll() {
  final boolean isEndAll = overTaskPb.getProgress() >= Integer.valueOf(taskCountTv.getText().toString());
  if (isEndAll) {
    Log.d(TAG, String.format("start[%d] over[%d]", GlobalMonitor.getImpl().getMarkStart(),
        GlobalMonitor.getImpl().getMarkOver()));
    stopTimeCount();
    actionBtn.setTag(true);
    actionBtn.setText("Start");
    taskCountSb.setEnabled(true);
  }
}

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

txtName.setText(score.getName());
Button b = (Button)convertView.findViewById(R.id.deletePlayer);
b.setTag(position);
b.setOnClickListener(new View.OnClickListener() {
     public void onClick(View v) {

代码示例来源:origin: Bigkoo/Android-PickerView

Button btnCancel = (Button) findViewById(R.id.btnCancel);
btnSubmit.setTag(TAG_SUBMIT);
btnCancel.setTag(TAG_CANCEL);

代码示例来源:origin: lingochamp/FileDownloader

resetDisplayData();
actionBtn.setTag(true);
actionBtn.setOnClickListener(new View.OnClickListener() {
  @Override

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

choice.setTag("" + i);
choice.setOnClickListener(new View.OnClickListener(){
 @Override

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

private Button getButton(String text, int position) {
  // 动态生成选择按钮
  final Button button = new Button(mContext);
  button.setText(text);
  button.setTag(position);
  button.setTextColor(mBuilder.getItemTextColor());
  button.setTextSize(mBuilder.getItemTextSize());
  button.setLayoutParams(new LinearLayout.LayoutParams(AbsListView.LayoutParams
      .MATCH_PARENT, mBuilder.getItemHeight()));
  button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View arg0) {
      if (mBuilder.getOnItemListener() != null) {
        selectPosition = Integer.parseInt(button.getTag().toString());
        mBuilder.getOnItemListener().onItemClick(button, selectPosition);
      }
    }
  });
  return button;
}

代码示例来源:origin: Bilibili/DanmakuFlameMaster

timer = new Timer();
  timer.schedule(new AsyncAddTask(), 0, 1000);
  mBtnSendDanmakus.setTag(true);
} else {
  mBtnSendDanmakus.setText(R.string.send_danmakus);
  mBtnSendDanmakus.setTag(false);

代码示例来源:origin: Bilibili/DanmakuFlameMaster

timer = new Timer();
  timer.schedule(new AsyncAddTask(), 0, 1000);
  mBtnSendDanmakus.setTag(true);
} else {
  mBtnSendDanmakus.setText(R.string.send_danmakus);
  mBtnSendDanmakus.setTag(false);

代码示例来源:origin: Bigkoo/Android-PickerView

Button btnCancel = (Button) findViewById(R.id.btnCancel);
btnSubmit.setTag(TAG_SUBMIT);
btnCancel.setTag(TAG_CANCEL);
btnSubmit.setOnClickListener(this);
btnCancel.setOnClickListener(this);

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

private Button getButton(String text, int position) {
  // 动态生成选择按钮
  final Button button = new Button(mContext);
  button.setText(text);
  button.setTag(position);
  button.setTextColor(mBuilder.getItemTextColor());
  button.setTextSize(mBuilder.getItemTextSize());
  LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams
      .MATCH_PARENT, mBuilder.getItemHeight());
  button.setLayoutParams(lp);
  button.setGravity(Gravity.LEFT|Gravity.CENTER_VERTICAL);
  button.setPadding(UiUtils.dp2px(mContext,10),0,UiUtils.dp2px(mContext,10),0);
  button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View arg0) {
      if (mBuilder.getOnItemListener() != null) {
        selectPosition = Integer.parseInt(button.getTag().toString());
        mBuilder.getOnItemListener().onItemClick(button, selectPosition);
      }
    }
  });
  return button;
}

代码示例来源:origin: rey5137/material

mEndDateButton.setTag(date);

代码示例来源:origin: lingochamp/FileDownloader

holder.taskActionBtn.setTag(holder);
holder.taskNameTv.setText(model.getName());

代码示例来源:origin: doggycoder/AndroidOpenGLDemo

public void setPosition(int position){
    MenuBean bean=data.get(position);
    mBtn.setText(bean.name);
    mBtn.setTag(position);
  }
}

代码示例来源:origin: fire3/sailorcast

@Override
  public void run() {
    mDlnaNorButton.setVisibility(View.VISIBLE);
    mPlayNorButton.setVisibility(View.VISIBLE);
    mPlayNorButton.setTag(R.id.key_video_url, urlNormal);
    mPlayNorButton.setTag(R.id.key_video, v);
    mPlayNorButton.setTag(R.id.key_video_number_in_album, mVideoInAlbum);
    mDlnaNorButton.setTag(R.id.key_video_url, urlNormal);
    mDlnaNorButton.setTag(R.id.key_video, v);
    mDlnaNorButton.setTag(R.id.key_video_number_in_album, mVideoInAlbum);
  }
});

代码示例来源:origin: fire3/sailorcast

@Override
  public void run() {
    mDlnaSuperButton.setVisibility(View.VISIBLE);
    mPlaySuperButton.setVisibility(View.VISIBLE);
    mPlaySuperButton.setTag(R.id.key_video_url, urlSuper);
    mPlaySuperButton.setTag(R.id.key_video, v);
    mPlaySuperButton.setTag(R.id.key_video_number_in_album, mVideoInAlbum);
    mDlnaSuperButton.setTag(R.id.key_video_url,urlSuper);
    mDlnaSuperButton.setTag(R.id.key_video,v);
    mDlnaSuperButton.setTag(R.id.key_video_number_in_album, mVideoInAlbum);
  }
});

代码示例来源:origin: fire3/sailorcast

@Override
  public void run() {
    mDlnaNorButton.setVisibility(View.VISIBLE);
    mPlayNorButton.setVisibility(View.VISIBLE);
    mPlayNorButton.setTag(R.id.key_video_url, urlNormal);
    mPlayNorButton.setTag(R.id.key_video, v);
    mPlayNorButton.setTag(R.id.key_video_number_in_album, mVideoInAlbum);
    mDlnaNorButton.setTag(R.id.key_video_url, urlNormal);
    mDlnaNorButton.setTag(R.id.key_video, v);
    mDlnaNorButton.setTag(R.id.key_video_number_in_album, mVideoInAlbum);
  }
});

相关文章

Button类方法