【问题标题】:Cannot resolve symbol 'setAdapter' (Spinner)无法解析符号“setAdapter”(微调器)
【发布时间】:2016-04-18 03:04:29
【问题描述】:

我正在尝试在我的应用程序中实现 MaterialBetterSpinner (https://github.com/Lesilva/BetterSpinner),但我得到了 “无法解析符号'setAdaptor'”错误。

这是处理材质微调器的块:

ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this,
        android.R.layout.simple_dropdown_item_1line, COUNTRIES);
MaterialBetterSpinner materialDesignSpinner = (MaterialBetterSpinner)
        findViewById(R.id.spinner);
materialDesignSpinner.setAdapter(arrayAdapter);

这是我的 xml 文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
android:orientation="vertical">

<com.weiwangcn.betterspinner.library.material.MaterialBetterSpinner
    android:id="@+id/spinner"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/source"
    android:textColorHint="#05ab9a"
    app:met_floatingLabel="normal"
    android:layout_marginTop="150dp" />
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Button"
    android:id="@+id/button"
    android:layout_gravity="center_horizontal"
    style="@style/Base.Widget.AppCompat.Button.Borderless"
    android:layout_marginTop="20dp" />

</LinearLayout>

【问题讨论】:

  • 什么是“适配器”?你的意思是“适应Er”?
  • 它们在代码块中的拼写实际上是正确的。
  • 感谢@pskink 的拼写检查

标签: android android-studio spinner android-arrayadapter


【解决方案1】:

解决了!

我不小心在 onCreate 函数之外编写了代码。

哈哈

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多