1

我在 Kotlin的伴生对象中有以下参数

    companion object Constants {
    /**
     * Values for the various type of connection that a device can have.
     */
    const val CONNECTION_KEY = "Connection_type"
    const val CONNECTION_AUX = "AUX"
    const val CONNECTION_BLUETOOTH = "Bluetooth"
    const val CONNECTION_USB = "USB"

    /**
     * Unique IDs respectively for devices and media elements.
     */
    const val DEVICE_ID_KEY = "Device_ID"
    const val MEDIA_ID_KEY = "Media_ID"

    /**
     * Various keys that you can find in [Bundle] returned by [getMediaItems].
     */
    const val MEDIA_NAME_KEY = "Media_name"
    const val SONG_IDS_KEY = "Songs_ids"
    const val GENRE_IDS_KEY = "Genres_ids"
    const val ARTIST_IDS_KEY = "Artists_ids"
}

问题是,在Kdoc结果中,我按字母顺序找到它们

ARTIST_IDS_KEY

const val ARTIST_IDS_KEY:字符串

CONNECTION_AUX

const val CONNECTION_AUX:字符串

CONNECTION_蓝牙

const val CONNECTION_BLUETOOTH:字符串

CONNECTION_KEY

设备可以具有的各种连接类型的值。

const val CONNECTION_KEY:字符串

连接_USB

const val CONNECTION_USB:字符串

DEVICE_ID_KEY

设备和媒体元素的唯一 ID。

const val DEVICE_ID_KEY:字符串

GENRE_IDS_KEY

const val GENRE_IDS_KEY:字符串

MEDIA_ID_KEY

const val MEDIA_ID_KEY:字符串

MEDIA_NAME_KEY

您可以在 getMediaItems 返回的 Bundle 中找到各种键。

const val MEDIA_NAME_KEY:字符串

SONG_IDS_KEY

const val SONG_IDS_KEY:字符串

...有没有办法维持原始订单?

4

1 回答 1

2

您可以通过在代码中对元素进行分组来对kDoc中的元素进行分组:

companion object Constants {
    /**
     * Values for the various type of connection that a device can have.
     */
    object Connection {
        const val KEY = "Connection_type"
        const val AUX = "AUX"
        const val BLUETOOTH = "Bluetooth"
        const val USB = "USB"
    }

    /**
     * Unique IDs respectively for devices and media elements.
     */
    object IDs {
        const val DEVICE = "Device_ID"
        const val MEDIA = "Media_ID"
    }

    /**
     * Various keys that you can find in [Bundle] returned by [getMediaItems].
     */
    object BundleKeys {
        const val MEDIA_NAME = "Media_name"
        const val SONG_IDS = "Songs_ids"
        const val GENRE_IDS = "Genres_ids"
        const val ARTIST_IDS = "Artists_ids"   
    }
}
于 2019-11-16T21:30:12.537 回答