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

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

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

Button.getParent介绍

暂无

代码示例

代码示例来源:origin: chat-sdk/chat-sdk-android

((ViewGroup) btnFacebook.getParent()).removeView(btnFacebook);
((ViewGroup) btnTwitter.getParent()).removeView(btnTwitter);
((ViewGroup) btnGoogle.getParent()).removeView(btnGoogle);
((ViewGroup) btnAnonymous.getParent()).removeView(btnAnonymous);

代码示例来源:origin: kristiyanP/colorpicker

/**
 * Add a  Button
 *
 * @param text     title of button
 * @param button   button to be added
 * @param listener listener
 * @return this
 */
public ColorPicker addListenerButton(String text, Button button, final OnButtonListener listener) {
  button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      listener.onClick(v, colorViewAdapter.getColorPosition(), colorViewAdapter.getColorSelected());
    }
  });
  button.setText(text);
  if (button.getParent() != null)
    buttons_layout.removeView(button);
  buttons_layout.addView(button);
  return this;
}

代码示例来源:origin: mtotschnig/MyExpenses

/**
 * Create a button according to this button item.
 *
 * @param parent The parent of the button, used to retrieve the theme and context for this
 *               button.
 * @return A button that can be added to the parent.
 */
protected Button createButton(ViewGroup parent) {
  if (mButton == null) {
    Context context = parent.getContext();
    if (mTheme != 0) {
      context = new ContextThemeWrapper(context, mTheme);
    }
    mButton = new Button(context);
    mButton.setOnClickListener(this);
  } else {
    if (mButton.getParent() instanceof ViewGroup) {
      // A view cannot be added to a different parent if one already exists. Remove this
      // button from its parent before returning.
      ((ViewGroup) mButton.getParent()).removeView(mButton);
    }
  }
  mButton.setEnabled(mEnabled);
  mButton.setText(mText);
  return mButton;
}

代码示例来源:origin: SwiftyWang/FingerColoring-Android

public void filterData(String filterStr) {
  try {
    ((View) footer.getParent()).setVisibility(View.GONE);
    search = filterStr;
    List<ThemeBean.Theme> filterDateList = new ArrayList<ThemeBean.Theme>();
    if (filterStr.isEmpty()) {
      refreshLayout.setEnabled(true);
      filterDateList = themelist;
    } else {
      refreshLayout.setEnabled(false);
      filterDateList.clear();
      for (ThemeBean.Theme theme : themelist) {
        if (theme.getN().toLowerCase(Locale.getDefault()).contains(filterStr.toLowerCase(Locale.getDefault())))
          filterDateList.add(theme);
      }
    }
    adapter.updateListView(filterDateList);
    alphaAdapter.notifyDataSetChanged();
  } catch (Exception e) {
  }
}

代码示例来源:origin: nyakokishi/ZhihuDaily

@Override
public void onClick(View v) {
  if (!CheckUtil.isMobile(username)) {
    Snackbar.make((View) registerBtn.getParent(), "请输入正确的手机号码", Snackbar.LENGTH_SHORT).show();
    return;
    Snackbar.make((View) registerBtn.getParent(), "验证码为六位数", Snackbar.LENGTH_SHORT).show();
    return;
    Snackbar.make((View) registerBtn.getParent(), "密码必须大于六位", Snackbar.LENGTH_SHORT).show();
    return;
  String password = MD5Util.getMd5Value(MD5Util.getMd5Value(rawPassword));
  user.setPassword(password);
  Snackbar.make((View) registerBtn.getParent(), "正在注册...", Snackbar.LENGTH_INDEFINITE).show();
  user.signOrLogin(getApplicationContext(), verifyCode, new SaveListener() {
    @Override

代码示例来源:origin: SwiftyWang/FingerColoring-Android

@Override
  public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    super.onScrolled(recyclerView, dx, dy);
    int visibleItemCount = layoutManager.getChildCount();
    int totalItemCount = layoutManager.getItemCount();
    int pastVisiblesItems = layoutManager.findFirstVisibleItemPosition();
    if (!isLoading && themelist == adapter.getList()) {
      //filter dont show footer view and not loading more items
      ((View) footer.getParent()).setVisibility(View.VISIBLE);
      if ((visibleItemCount + pastVisiblesItems) >= totalItemCount) {
        L.e("start loadmre");
        loadData(LoadModel.loadmore);
      }
    }
  }
});

代码示例来源:origin: nyakokishi/ZhihuDaily

rawPassword = passwordEt.getText().toString();
if (TextUtils.isEmpty(username)) {
  Snackbar.make((View) loginBtn.getParent().getParent(), "用户名不能为空", Snackbar.LENGTH_SHORT).show();
  return;
  Snackbar.make((View) loginBtn.getParent().getParent(), "密码不能为空", Snackbar.LENGTH_SHORT).show();
  return;
Snackbar.make((View) loginBtn.getParent().getParent(), "登陆中...", Snackbar.LENGTH_INDEFINITE).show();
String password = MD5Util.getMd5Value(MD5Util.getMd5Value(rawPassword));
BmobUser.loginByAccount(getApplicationContext(), username

代码示例来源:origin: nyakokishi/ZhihuDaily

@Override
  public void onClick(View v) {
      username = usernameEt.getText().toString();
    if (CheckUtil.isMobile(username)) {
      new TaskCodeButton().execute();
      BmobSMS.requestSMSCode(getApplicationContext(), username, "hello", new RequestSMSCodeListener() {
        @Override
        public void done(Integer smsId, BmobException ex) {
          // TODO Auto-generated method stub
          if (ex == null) {//验证码发送成功
            Log.i("smile", "短信id:" + smsId);//用于查询本次短信发送详情
          }
        }
      });
    } else {
      Snackbar.make((View) registerBtn.getParent(), "请输入正确的手机号码", Snackbar.LENGTH_SHORT).show();
    }
  }
});

代码示例来源:origin: wasdennnoch/AndroidN-ify

Button okButton = (Button) thisLayout.findViewById(okButtonId);
Button cancelButton = (Button) thisLayout.findViewById(cancelButtonId);
LinearLayout buttonContainer = (LinearLayout) okButton.getParent();
LinearLayout buttonContainerParent = (LinearLayout) buttonContainer.getParent();
TextView installConfirmQuestion = (TextView) thisLayout.findViewById(installConfirmQuestionId);

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

mLayout = (TableLayout) b1.getParent();

代码示例来源:origin: nyakokishi/ZhihuDaily

@Override
  public void onClick(View v) {
    final String newUsername = usernameEt.getText().toString();
    if (TextUtils.isEmpty(newUsername)){
      Snackbar.make((View) saveBtn.getParent(),"用户名不能为空",Snackbar.LENGTH_SHORT).show();
      return;
    }
    final User user = BmobUser.getCurrentUser(getApplicationContext(),User.class);
    user.setUsername(newUsername);
    user.update(getApplicationContext(), user.getObjectId(), new UpdateListener() {
      @Override
      public void onSuccess() {
        ZhihuApplication.user.setUsername(newUsername);
        setResult(RESULT_OK);
        finish();
      }
      @Override
      public void onFailure(int i, String s) {
      }
    });
  }
});

代码示例来源:origin: nyakokishi/ZhihuDaily

@Override
  public void onClick(View v) {
    final String newPassword = passwordEt.getText().toString();
    if (newPassword.length() < 6) {
      Snackbar.make((View) saveBtn.getParent(), "密码不能少于6位", Snackbar.LENGTH_SHORT).show();
      return;
    }
    BmobUser.updateCurrentUserPassword(getApplicationContext()
        , MD5Util.getMd5Value(MD5Util.getMd5Value(oldPassword))
        , MD5Util.getMd5Value(MD5Util.getMd5Value(newPassword))
        , new UpdateListener() {
      @Override
      public void onSuccess() {
        PreferenceUtil.setPrefString(getApplicationContext(), "password", newPassword);
        setResult(RESULT_OK);
        finish();
      }
      @Override
      public void onFailure(int code, String msg) {
        Snackbar.make((View) saveBtn.getParent(), msg, Snackbar.LENGTH_SHORT).show();
      }
    });
  }
});

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

if (dialogButton == null)
  return;
if (!(dialogButton.getParent() instanceof LinearLayout))
  return;            
final LinearLayout linearLayout = (LinearLayout) dialogButton.getParent();
linearLayout.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
  @Override

代码示例来源:origin: wasdennnoch/AndroidN-ify

((ViewGroup) doneButton.getParent()).removeAllViews();
buttonsPanel.removeAllViews();
((ViewGroup) centerExplanation.getParent()).removeAllViews();

代码示例来源:origin: corcoran/Hangar

LinearLayout parent = (LinearLayout) buttons[0].getParent();
parent.setGravity(Gravity.CENTER);
parent.setOrientation(LinearLayout.HORIZONTAL);

代码示例来源:origin: codechimp-org/AppRater

@Override
  public void onShow(DialogInterface dialog) {
    try {
      final Button buttonPositive = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
      if (buttonPositive == null) {
        return;
      }
      LinearLayout linearLayout = (LinearLayout)buttonPositive.getParent();
      if (linearLayout == null) {
        return;
      }
      // Check positive button not fits in window
      boolean shouldUseVerticalLayout = false;
      if (buttonPositive.getLeft() + buttonPositive.getWidth() > linearLayout.getWidth()) {
        shouldUseVerticalLayout = true;
      }
      // Change layout orientation to vertical
      if (shouldUseVerticalLayout ) {
        linearLayout.setOrientation(LinearLayout.VERTICAL);
        linearLayout.setGravity(Gravity.END);
      }
    } catch (Exception ignored) {
    }
  }
});

代码示例来源:origin: AndBible/and-bible

/** calculate button position relative to this table because MotionEvents are relative to this table
 */
private void recordButtonPositions() {
  for (ButtonInfo buttonInfo : buttonInfoList) {
    
    // get position of button within row
    Button button = buttonInfo.button;
    TableRow tableRow = (TableRow)button.getParent();
    
    buttonInfo.left += button.getLeft()+tableRow.getLeft();
    buttonInfo.top += button.getTop()+tableRow.getTop();
    buttonInfo.right += button.getRight()+tableRow.getLeft();
    buttonInfo.bottom += button.getBottom()+tableRow.getTop();
  }
  
  // calculate offset of 2 button heights so users can see the buttons surrounding the current button pressed
  if (buttonInfoList.size()>0) {
    ButtonInfo but1 = buttonInfoList.get(0);
    mPreviewOffset = but1.top - but1.bottom;
  }
}
/**

代码示例来源:origin: doc-rj/smartcard-reader

@Override
  public void onClick(View v) {
    if (mPopup != null) {
      mPopup.dismiss();
    }
    // update group list on click to make sure all recent input
    // (eg. type payment/other) is taken into account
    updateGrpList();
    // use a list popup window populated with checked textview rows
    ListPopupWindow popup = new ListPopupWindow(AppEditActivity.this, null);
    popup.setWidth(((View)mGrpButton.getParent()).getWidth());
    popup.setAnchorView(mGrpButton);
    popup.setAdapter(mGrpAdapter);
    popup.setOnItemClickListener(mItemClickListener);
    popup.show();
    mPopup = popup;
    // setup the popup window's listview
    ListView listView = popup.getListView();
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    int size = mGrpItems.size();
    for (int i = 0; i < size; i++) {
      listView.setItemChecked(i, mGrpItems.get(i).isChecked());
    }
  }
});

代码示例来源:origin: kristiyanP/colorpicker

if (button.getParent() != null)
  buttons_layout.removeView(button);

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

if (dropped.getParent() == dropTarget) {
  dropTarget.removeView(dropped);
  dropTarget.invalidate();

相关文章

Button类方法