android.widget.ImageButton类的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(13.0k)|赞(0)|评价(0)|浏览(219)

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

ImageButton介绍

暂无

代码示例

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

@Override
 public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
   if (convertView == null) {
     LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     convertView = inflater.inflate(R.layout.elv_group, null);
   }
   TextView tvItem = (TextView) convertView.findViewById(R.id.tvRecipeName);
   ImageButton ibDeleteRcipe = (ImageButton) convertView.findViewById(R.id.ibDeleteRecipe);
   ibDeleteRcipe.setOnClickListener(new OnClickListener() {
     @Override
     public void onClick(View v) {               
       ...
     }
   });
   ibDeleteRcipe.setFocusable(false);
   tvItem.setText(arrGroupElements[groupPosition]);
   return convertView;
 }

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

final View rowView = inflater.inflate(R.layout.row, null);
final ImageButton deleteButton = (ImageButton) rowView
    .findViewById(R.id.buttonDelete);
final EditText editText = (EditText) rowView
    .findViewById(R.id.editText);
if (name != null && !name.isEmpty()) {
  editText.setText(name);
} else {
  mExclusiveEmptyView = rowView;
  deleteButton.setVisibility(View.INVISIBLE);
      deleteButton.setVisibility(View.INVISIBLE);
      if (mExclusiveEmptyView != null
          && mExclusiveEmptyView != rowView) {
      deleteButton.setVisibility(View.VISIBLE);

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

@Override
public void initView() {
  mIbToolbarMore.setImageResource(R.mipmap.ic_session_info);
  mIbToolbarMore.setVisibility(View.VISIBLE);
  mElEmotion.attachEditText(mEtContent);
  initEmotionKeyboard();
  initRefreshLayout();
  setTitle();
}

代码示例来源:origin: koral--/android-gif-drawable

private void postInit(GifViewUtils.GifImageViewAttributes result) {
  mFreezesAnimation = result.freezesAnimation;
  if (result.mSourceResId > 0) {
    super.setImageResource(result.mSourceResId);
  }
  if (result.mBackgroundResId > 0) {
    super.setBackgroundResource(result.mBackgroundResId);
  }
}

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

private void showPostingProgress() {
  ensurePostingProgressInflated();
  fabPosting.setVisibility(View.VISIBLE);
  // if stub has just been inflated then it will not have been laid out yet
  if (fabPosting.isLaidOut()) {
    revealPostingProgress();
  } else {
    fabPosting.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
      @Override
      public void onLayoutChange(View v, int l, int t, int r, int b,
                    int oldL, int oldT, int oldR, int oldB) {
        fabPosting.removeOnLayoutChangeListener(this);
        revealPostingProgress();
      }
    });
  }
}

代码示例来源:origin: k9mail/k-9

view = convertView;
} else {
  view = getLayoutInflater().inflate(R.layout.accounts_item, parent, false);
AccountViewHolder holder = (AccountViewHolder) view.getTag();
if (holder == null) {
  holder = new AccountViewHolder();
  holder.description = view.findViewById(R.id.description);
  holder.email = view.findViewById(R.id.email);
  holder.newMessageCount = view.findViewById(R.id.new_message_count);
  holder.flaggedMessageCount = view.findViewById(R.id.flagged_message_count);
  holder.email.setText(SizeFormatter.formatSize(Accounts.this, stats.size));
  holder.email.setVisibility(View.VISIBLE);
} else {
  if (account.getEmail().equals(account.getDescription())) {
    holder.email.setVisibility(View.GONE);
  } else {
    holder.email.setVisibility(View.VISIBLE);
  holder.folders.setVisibility(View.GONE);
} else {
  holder.folders.setVisibility(View.VISIBLE);
  holder.folders.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {
      FolderList.actionHandleAccount(Accounts.this, (Account)account);

代码示例来源:origin: chentao0707/SimplifyReader

setOrientation(VERTICAL);
mProgressBar = (ProgressBar) LayoutInflater.from(context).inflate(R.layout.progress_horizontal, null);
mProgressBar.setMax(100);
mProgressBar.setProgress(0);
mBrowserControllerView = LayoutInflater.from(context).inflate(R.layout.browser_controller, null);
mGoBackBtn = (ImageButton) mBrowserControllerView.findViewById(R.id.browser_controller_back);
mGoForwardBtn = (ImageButton) mBrowserControllerView.findViewById(R.id.browser_controller_forward);
mGoBrowserBtn = (ImageButton) mBrowserControllerView.findViewById(R.id.browser_controller_go);
mRefreshBtn = (ImageButton) mBrowserControllerView.findViewById(R.id.browser_controller_refresh);
mGoBackBtn.setOnClickListener(new OnClickListener() {
mGoForwardBtn.setOnClickListener(new OnClickListener() {
mRefreshBtn.setOnClickListener(new OnClickListener() {
mGoBrowserBtn.setOnClickListener(new OnClickListener() {

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

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  ActionBar ab = getSherlock().getActionBar();
  LayoutInflater li = LayoutInflater.from(this);
  View customView = li.inflate(R.layout.my_custom_view, null);
  ab.setCustomView(customView);

  ImageButton ibItem1 = (ImageButton) customView.findViewById(R.id.item1);
  ibItem1.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
      // ...
    }
  });

  ImageButton ibItem2 = (ImageButton) customView.findViewById(R.id.item2);
  ibItem2.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
      // ...
    }
  });
}

代码示例来源:origin: syncthing/syncthing-android

public View getView(int position, View convertView, @NonNull ViewGroup parent) {
  ItemFolderListBinding binding = (convertView == null)
      ? DataBindingUtil.inflate(LayoutInflater.from(mContext), R.layout.item_folder_list, parent, false)
      : DataBindingUtil.bind(convertView);
  binding.label.setText(TextUtils.isEmpty(folder.label) ? folder.id : folder.label);
  binding.directory.setText(folder.path);
  binding.override.setOnClickListener(v -> {
    Intent intent = new Intent(mContext, SyncthingService.class)
        .putExtra(SyncthingService.EXTRA_FOLDER_ID, folder.id);
    intent.setAction(SyncthingService.ACTION_OVERRIDE_CHANGES);
    mContext.startService(intent);
  });
  binding.openFolder.setOnClickListener(v -> {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(new File(folder.path)), "resource/folder");

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

private void setUpWebControls(View view) {
  view.findViewById(R.id.toolbar_web).setOnClickListener(v -> scrollToTop());
  view.findViewById(R.id.button_back).setOnClickListener(v -> mWebView.goBack());
  view.findViewById(R.id.button_forward).setOnClickListener(v -> mWebView.goForward());
  view.findViewById(R.id.button_clear).setOnClickListener(v -> {
    mControls.showNext();
  });
  mButtonRefresh.setOnClickListener(v -> {
    if (mWebView.getProgress() < 100) {
      mWebView.stopLoading();
  view.findViewById(R.id.button_exit).setOnClickListener(v ->
      LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(
          new Intent(WebFragment.ACTION_FULLSCREEN)
              .putExtra(EXTRA_FULLSCREEN, false)));
  mButtonNext.setOnClickListener(v -> mWebView.findNext(true));
  mButtonMore.setOnClickListener(v ->

代码示例来源:origin: HotBitmapGG/bilibili-android-client

private void initControllerView(View v) {
  mPauseButton = (ImageButton) v.findViewById(R.id.media_controller_play_pause);
  mTvPlay = (ImageView) v.findViewById(R.id.media_controller_tv_play);
  if (mPauseButton != null && mTvPlay != null) {
    mPauseButton.requestFocus();
    mPauseButton.setOnClickListener(mPauseListener);
    mTvPlay.requestFocus();
    mTvPlay.setOnClickListener(v13 -> {
    });
  mProgress = (SeekBar) v.findViewById(R.id.media_controller_seekbar);
  if (mProgress != null) {
    if (mProgress instanceof SeekBar) {
  mTitleView = (TextView) v.findViewById(R.id.media_controller_title);
  if (mTitleView != null) {
    mTitleView.setText(mTitle);
  LinearLayout mDanmakuLayout = (LinearLayout) v.findViewById(

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

public class tab2 extends Fragment {  
@Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

    View view =inflater.inflate(R.layout.tab2,container,false);

    ImageButton pigsButton = (ImageButton) view.findViewById(R.id.pigsButton);

    pigsButton.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        Intent i = new Intent(tab2.this, pigs_story.class);
        startActivity(i);
      }
    });

    return view;
  }

}

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

protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  ImageButton saldoButton = (ImageButton)findViewById(R.id.saldoButton);

  saldoButton.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
      Log.d("This Class", "I am a working button!");
      Intent intent = new Intent(this, NewClass.class);
      this.startActivity(intent);

    }
  });
}

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

sherlockTitle.setVisibility(View.GONE);
sherlockDivider.setVisibility(View.GONE);
titleArea.setVisibility(View.VISIBLE);
TextView titleView = (TextView) titleArea.findViewById(R.id.custom_title);
if (titleView != null) {
  titleView.setText(R.string.tag_dialog_title);
ImageButton cancelBtn = (ImageButton) titleArea.findViewById(R.id.cancel_btn);
cancelBtn.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
cancelBtn.setVisibility(View.VISIBLE);
ImageButton okBtn = (ImageButton) titleArea.findViewById(R.id.ok_btn);
okBtn.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
okBtn.setVisibility(View.VISIBLE);

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

@Override
public void initListener() {
  mIbToolbarMore.setOnClickListener(v -> {
    Intent intent = new Intent(SessionActivity.this, SessionInfoActivity.class);
    intent.putExtra("sessionId", mSessionId);
    intent.putExtra("sessionType", mConversationType == mConversationType.PRIVATE ? SessionActivity.SESSION_TYPE_PRIVATE : SessionActivity.SESSION_TYPE_GROUP);
    jumpToActivity(intent);
  });

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

bindFavorite();
mSessionManager.view(story.getId());
mVoteButton.setVisibility(View.VISIBLE);
mVoteButton.setOnClickListener(v -> vote(story));
final TextView titleTextView = findViewById(android.R.id.text2);
if (story.isStoryType()) {
  titleTextView.setText(story.getDisplayedTitle());
  setTaskTitle(story.getDisplayedTitle());
  if (!TextUtils.isEmpty(story.getSource())) {
    TextView sourceTextView = findViewById(R.id.source);
    sourceTextView.setText(story.getSource());
    sourceTextView.setVisibility(View.VISIBLE);
        .setItem(story)
        .setShowArticle(hasText || !mExternalBrowser)
        .setCacheMode(getIntent().getIntExtra(EXTRA_CACHE_MODE, ItemManager.MODE_DEFAULT))
        .setRetainInstance(true)
        .setDefaultViewMode(mStoryViewMode));

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

mMainMenuButton.setBackground(null);
mMainMenuButton.setImageDrawable(menuIcon);
mMainMenuButton.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
LayoutInflater inflater = getLayoutInflater();
View popupView = inflater.inflate(R.layout.menu_layout, null);
VerticalLabelView menuItem1 = (VerticalLabelView)popupView.findViewById(R.id.menu_item1);
menuItem1.setOnClickListener(mOnMenuItemClickListener);
menuItem1.setText("Vertical menu item 1");
menuItem1.setTextSize(mTextSize);
VerticalLabelView menuItem2 = (VerticalLabelView)popupView.findViewById(R.id.menu_item2);
menuItem2.setOnClickListener(mOnMenuItemClickListener);
menuItem2.setText("Vertical menu item 2");
menuItem2.setTextSize(mTextSize);
VerticalLabelView menuItem3 = (VerticalLabelView)popupView.findViewById(R.id.menu_item3);
menuItem3.setOnClickListener(mOnMenuItemClickListener);
menuItem3.setText("Vertical menu item 3");

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

if (v == null) {
  LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  v = vi.inflate(R.layout.item, null);
  textlInfo.setText(o.getName());
  button.setImageResource(R.drawable.icon);
  v.setOnCreateContextMenuListener(this);

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

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
  View view = convertView;
  if (view == null){
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view = inflater.inflate(R.layout.list_layout_ip_addtional_users, null);
  }

  //Handle TextView and display string from your list
  TextView listItemText2 = (TextView)view.findViewById(R.id.list_item_string_name);
  listItemText2.setText(list.get(position));

  ImageButton button8 = (ImageButton) view.findViewById(R.id.ip_additional_user_edit);
  button8.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
      Intent intent = new Intent(context, IPAdditionalUsersEdit.class);
      context.startActivity(intent);
    }
  });

  return view;
}

代码示例来源:origin: BaronZ88/MinimalistWeather

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
  Weather weather = weatherList.get(position);
  holder.city.setText(weather.getCityName());
  holder.weather.setText(weather.getWeatherLive().getWeather());
  holder.temp.setText(new StringBuilder().append(weather.getWeatherForecasts().get(0).getTempMin()).append("~").append(weather.getWeatherForecasts().get(0).getTempMax()).append("℃").toString());
  holder.publishTime.setText("发布于 " + DateConvertUtils.timeStampToDate(weather.getWeatherLive().getTime(), DateConvertUtils.DATA_FORMAT_PATTEN_YYYY_MM_DD_HH_MM));
  holder.deleteButton.setOnClickListener(v -> {
    Weather removeWeather = weatherList.get(holder.getAdapterPosition());
    weatherList.remove(removeWeather);
    notifyItemRemoved(holder.getAdapterPosition());
    if (onItemClickListener != null && onItemClickListener instanceof OnCityManagerItemClickListener) {
      ((OnCityManagerItemClickListener) onItemClickListener).onDeleteClick(removeWeather.getCityId());
    }
  });
}

相关文章

ImageButton类方法