android.widget.Spinner.getPaddingRight()方法的使用及代码示例

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

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

Spinner.getPaddingRight介绍

暂无

代码示例

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

Spinner s = (Spinner) findViewById(R.id.spinner);
s.setPadding(0, s.getPaddingTop(), s.getPaddingRight(), s.getPaddingBottom());

代码示例来源:origin: Ronak-LM/memoir

private <T extends SpinnerItem> SpinnerItemAdapter<T> createDropDownNav(Spinner spinner, int spinnerId, int spinnerItemId,
                                    SpinnerItems<T> spinnerItems,
                                    final DropDownNavListener<T> listener) {
  if (spinner != null) {
    Context context = getContext();
    // create custom adapter
    final SpinnerItemAdapter<T> dropDownNavAdapter = new SpinnerItemAdapter<>(context, spinnerItems, spinnerId, spinnerItemId);
    // configure spinner
    spinner.setPadding(spinner.getPaddingLeft(), 0, spinner.getPaddingRight(), 0);
    spinner.setAdapter(dropDownNavAdapter);
    // we need this because otherwise the first item will be selected by
    // default and the OnItemSelectedListener won't get called
    spinner.setSelection(spinnerItems.getSelectedItem());
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
      private AtomicBoolean mFirstCall = new AtomicBoolean(true);
      @Override
      public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
        if (!mFirstCall.getAndSet(false) && dropDownNavAdapter.getSelectedItem() != position) {
          listener.onItemSelected(dropDownNavAdapter.getItem(position), position);
        }
        dropDownNavAdapter.setSelectedItem(position);
      }
      @Override
      public void onNothingSelected(AdapterView<?> parent) {
      }
    });
    return dropDownNavAdapter;
  }
  return null;
}

相关文章