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

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

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

Spinner.getContext介绍

暂无

代码示例

代码示例来源:origin: square/assertj-android

public SpinnerAssert hasPrompt(int resId) {
  isNotNull();
  return hasPrompt(actual.getContext().getString(resId));
 }
}

代码示例来源:origin: vinc3m1/RoundedImageView

@Override protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.example_activity);
 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
 Spinner navSpinner = (Spinner) findViewById(R.id.spinner_nav);
 navSpinner.setAdapter(ArrayAdapter.createFromResource(
   navSpinner.getContext(),
   R.array.action_list,
   android.R.layout.simple_spinner_dropdown_item));
 navSpinner.setOnItemSelectedListener(this);
 if (savedInstanceState == null) {
  navSpinner.setSelection(0);
 }
}

代码示例来源:origin: matburt/mobileorg-android

public static void setupSpinner(Spinner spinner, ArrayList<String> data,
                String selection) {
  if(!TextUtils.isEmpty(selection) && !data.contains(selection))
    data.add(selection);
  ArrayAdapter<String> adapter = new ArrayAdapter<String>(spinner.getContext(),
      android.R.layout.simple_spinner_item, data);
  adapter.setDropDownViewResource(R.layout.edit_spinner_layout);
  spinner.setAdapter(adapter);
  int pos = data.indexOf(selection);
  if (pos < 0) {
    pos = 0;
  }
  spinner.setSelection(pos, true);
}

代码示例来源:origin: dotWee/MicroPinner

private void setVisibilityAdapter() {
  if (spinnerVisibility != null) {
    ArrayAdapter<String> visibilityAdapter =
        new ArrayAdapter<>(spinnerVisibility.getContext(), android.R.layout.simple_spinner_item,
            this.getResources().getStringArray(R.array.array_visibilities));
    visibilityAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerVisibility.setAdapter(visibilityAdapter);
  }
}

代码示例来源:origin: markusfisch/ShaderEditor

private void initSpinner(Spinner spinner, int namesId) {
  ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
      spinner.getContext(),
      namesId,
      android.R.layout.simple_spinner_item);
  adapter.setDropDownViewResource(
      android.R.layout.simple_spinner_dropdown_item);
  spinner.setAdapter(adapter);
}

代码示例来源:origin: MCMrARM/revolution-irc

private void refreshSpinner() {
  mSpinnerOptionUUIDs = new ArrayList<>();
  List<String> options = new ArrayList<>();
  options.add(mServerSpinner.getContext().getString(R.string.value_any));
  mSpinnerOptionUUIDs.add(null);
  for (ServerConfigData data :
      ServerConfigManager.getInstance(mServerSpinner.getContext()).getServers()) {
    options.add(data.name);
    mSpinnerOptionUUIDs.add(data.uuid);
  }
  ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(mServerSpinner.getContext(),
      R.layout.simple_spinner_item, android.R.id.text1, options);
  spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  mServerSpinner.setAdapter(spinnerAdapter);
}

代码示例来源:origin: dotWee/MicroPinner

private void setPriorityAdapter() {
  if (spinnerPriority != null) {
    ArrayAdapter<String> priorityAdapter =
        new ArrayAdapter<>(spinnerPriority.getContext(), android.R.layout.simple_spinner_item,
            this.getResources().getStringArray(R.array.array_priorities));
    priorityAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerPriority.setAdapter(priorityAdapter);
  }
}

代码示例来源:origin: consp1racy/android-support-preference

public static void setEntries(@NonNull final Spinner spinner, @NonNull final CharSequence[] entries) {
  final Context context = spinner.getContext();
  final CheckedTypedItemAdapter<CharSequence> adapter = new CheckedTypedItemAdapter<>(context, android.R.layout.simple_spinner_item, android.R.id.text1, entries);
  adapter.setDropDownViewResource(R.layout.asp_simple_spinner_dropdown_item);
  spinner.setAdapter(adapter);
}

代码示例来源:origin: com.squareup.assertj/assertj-android

public SpinnerAssert hasPrompt(int resId) {
  isNotNull();
  return hasPrompt(actual.getContext().getString(resId));
 }
}

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

@BindingAdapter(value = {"selectedItem", "entries"}, requireAll = false)
public static void setSelectedItem(Spinner spinner, SpinnerItem spinnerItem,
    List<? extends SpinnerItem> spinnerItems) {
  // Set entries attribute when provided
  if (spinnerItems != null) {
    for (int i = 0; i < spinnerItems.size(); i++) {
      spinnerItems.get(i).setIndex(i);
    }
    ArrayAdapter<? extends SpinnerItem> adapter =
      new ArrayAdapter<>(spinner.getContext(), R.layout.spinner_item, spinnerItems);
    spinner.setAdapter(adapter);
  }
  // set selectedItem attribute when provided
  if (spinnerItem != null) {
    if (spinner.getAdapter() == null) {
      return;
    }
    // Other code omitted for simplicity
  }
}

代码示例来源:origin: consp1racy/android-support-preference

public static void setEntries(@NonNull final Spinner spinner, @ArrayRes final int entriesResId) {
  final Context context = spinner.getContext();
  final CharSequence[] entries = context.getResources().getTextArray(entriesResId);
  final CheckedTypedItemAdapter<CharSequence> adapter = new CheckedTypedItemAdapter<>(context, android.R.layout.simple_spinner_item, android.R.id.text1, entries);
  adapter.setDropDownViewResource(R.layout.asp_simple_spinner_dropdown_item);
  spinner.setAdapter(adapter);
}

代码示例来源:origin: philburk/android-midisuite

mType = type;
mSpinner = (Spinner) activity.findViewById(spinnerId);
mAdapter = new ArrayAdapter<>(mSpinner.getContext(),
    android.R.layout.simple_spinner_item);
mAdapter.setDropDownViewResource(

相关文章