我在哪里可以找到 AndroidX 中的 simple_spinner_item?

Where can I find simple_spinner_item in AndroidX?

我在我的应用程序中使用了一个 ArrayAdapter,它是这样初始化的:

myAdapter = new ArrayAdapter(context, 
    android.R.layout.simple_spinner_item,
    myList
);

AndroidX包中android.R.layout.simple_spinner_item的对应在哪里可以找到?

(在 Android Studio 中)如果您右键单击它并选择转到声明,您会发现以下内容:

 <?xml version="1.0" encoding="utf-8"?>
    <!--
    /* //device/apps/common/assets/res/any/layout/simple_spinner_item.xml
    **
    ** Copyright 2006, The Android Open Source Project
    **
    ** Licensed under the Apache License, Version 2.0 (the "License"); 
    ** you may not use this file except in compliance with the License. 
    ** You may obtain a copy of the License at 
    **
    **     http://www.apache.org/licenses/LICENSE-2.0 
    **
    ** Unless required by applicable law or agreed to in writing, software 
    ** distributed under the License is distributed on an "AS IS" BASIS, 
    ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
    ** See the License for the specific language governing permissions and 
    ** limitations under the License.
    */
    -->
    <TextView xmlns:android="http://schemas.android.com/apk/res/android" 
        android:id="@android:id/text1"
        style="?android:attr/spinnerItemStyle"
        android:singleLine="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ellipsize="marquee"
        android:textAlignment="inherit"/>

评论后编辑:

simple_spinner_item was added on API 1 所以 Android 的所有版本都支持它。 AndroidX 是作为支持库的延续出现的,这些支持库用于在更新的 API 中添加并需要向后兼容的功能。在这种情况下,它不会影响此特定布局的使用,因为它在所有版本中都可用。您可以继续使用它。我将保留上面的布局内容,以防万一您想要覆盖样式并按照上面的评论中提到的那样对其进行自定义。

所有布局位于:sdk\platforms\android-xx\data\res\layout 查看布局的XML:

Eclipse:只需在代码中的某处键入 android.R.layout.simple_spinner_item,按住 Ctrl,将鼠标悬停在 simple_spinner_item 上,然后从出现的下拉列表中选择 select "Open declaration in layout/simple_spinner_item.xml"。它会将您引导至 XML.

的内容

Android Studio: Project Window -> External Libraries -> Android X Platform -> res -> layout,这里您将看到可用布局的列表。