1e41f4b71Sopenharmony_ci# AlphabetIndexer 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **AlphabetIndexer** component can create a logically indexed array of items in a container for instant location. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci## Child Components 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ciNot supported 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci## APIs 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ciAlphabetIndexer(value: {arrayValue: Array<string>, selected: number}) 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci**Parameters** 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 26e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 27e41f4b71Sopenharmony_ci| arrayValue | Array<string> | Yes| Array of strings to be displayed in the alphabetic index bar. The value cannot be null.| 28e41f4b71Sopenharmony_ci| selected | number | Yes | Index of the initially selected item. If the value exceeds the value range, the default value 0 is used.<br>Since API version 10, this parameter supports two-way binding through [$$](../../../quick-start/arkts-two-way-sync.md).| 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci## Attributes 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ciWhen the [width](ts-universal-attributes-size.md#width) attribute is set to **"auto"**, the width is adaptive. This means that the width will adjust according to the maximum width of the index items. 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ciThe default value of the [padding](ts-universal-attributes-size.md#padding) attribute is 4 vp. 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ciIn addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported. 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci### color 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_cicolor(value: ResourceColor) 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ciSets the font color. 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 45e41f4b71Sopenharmony_ci 46e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ci**Parameters** 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 51e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ----------------------------------- | 52e41f4b71Sopenharmony_ci| value | [ResourceColor](ts-types.md#resourcecolor) | Yes | Font color.<br>Default value: **0x99182431**| 53e41f4b71Sopenharmony_ci 54e41f4b71Sopenharmony_ci### selectedColor 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ciselectedColor(value: ResourceColor) 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ciSets the font color of the selected item. 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 61e41f4b71Sopenharmony_ci 62e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 63e41f4b71Sopenharmony_ci 64e41f4b71Sopenharmony_ci**Parameters** 65e41f4b71Sopenharmony_ci 66e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 67e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ----------------------------------------- | 68e41f4b71Sopenharmony_ci| value | [ResourceColor](ts-types.md#resourcecolor) | Yes | Font color of the selected item.<br>Default value: **0xFF007DFF**| 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ci### popupColor 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_cipopupColor(value: ResourceColor) 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ciSets the font color of the pop-up text. 75e41f4b71Sopenharmony_ci 76e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 77e41f4b71Sopenharmony_ci 78e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ci**Parameters** 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 83e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ------------------------------------------- | 84e41f4b71Sopenharmony_ci| value | [ResourceColor](ts-types.md#resourcecolor) | Yes | Font color of the pop-up text.<br>Default value: **0xFF007DFF**| 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ci### selectedBackgroundColor 87e41f4b71Sopenharmony_ci 88e41f4b71Sopenharmony_ciselectedBackgroundColor(value: ResourceColor) 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ciSets the background color of the selected item. 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 95e41f4b71Sopenharmony_ci 96e41f4b71Sopenharmony_ci**Parameters** 97e41f4b71Sopenharmony_ci 98e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 99e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ----------------------------------------- | 100e41f4b71Sopenharmony_ci| value | [ResourceColor](ts-types.md#resourcecolor) | Yes | Background color of the selected item.<br>Default value: **0x1A007DFF**| 101e41f4b71Sopenharmony_ci 102e41f4b71Sopenharmony_ci### popupBackground 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_cipopupBackground(value: ResourceColor) 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ciSets the background color of the pop-up text. 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 109e41f4b71Sopenharmony_ci 110e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 111e41f4b71Sopenharmony_ci 112e41f4b71Sopenharmony_ci**Parameters** 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 115e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ------------------------------------------------------------ | 116e41f4b71Sopenharmony_ci| value | [ResourceColor](ts-types.md#resourcecolor) | Yes | Background color of the pop-up text.<br>Default value:<br>API version 11 and earlier: **0xFFFFFFFF**<br>API version 12 and later: **#66808080**| 117e41f4b71Sopenharmony_ci 118e41f4b71Sopenharmony_ci### usingPopup 119e41f4b71Sopenharmony_ci 120e41f4b71Sopenharmony_ciusingPopup(value: boolean) 121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_ciSets whether to use pop-up text. 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 125e41f4b71Sopenharmony_ci 126e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_ci**Parameters** 129e41f4b71Sopenharmony_ci 130e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 131e41f4b71Sopenharmony_ci| ------ | ------- | ---- | -------------------------------------- | 132e41f4b71Sopenharmony_ci| value | boolean | Yes | Whether to use pop-up text.<br>Default value: **false**| 133e41f4b71Sopenharmony_ci 134e41f4b71Sopenharmony_ci### selectedFont 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ciselectedFont(value: Font) 137e41f4b71Sopenharmony_ci 138e41f4b71Sopenharmony_ciSets the font style of the selected item. 139e41f4b71Sopenharmony_ci 140e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 141e41f4b71Sopenharmony_ci 142e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 143e41f4b71Sopenharmony_ci 144e41f4b71Sopenharmony_ci**Parameters** 145e41f4b71Sopenharmony_ci 146e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 147e41f4b71Sopenharmony_ci| ------ | ------------------------ | ---- | ------------------------------------------------------------ | 148e41f4b71Sopenharmony_ci| value | [Font](ts-types.md#font) | Yes | Font style of the selected item.<br>Default value:<br>API version 11 and earlier:<br>{<br>size:'12.0fp',<br> style:FontStyle.Normal,<br> weight:FontWeight.Normal,<br> family:'HarmonyOS Sans'<br>}<br>API version 12 and later:<br>{<br>size:'10.0vp',<br> style:FontStyle.Normal,<br> weight:FontWeight.Medium,<br> family:'HarmonyOS Sans'<br>} | 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci### popupFont 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_cipopupFont(value: Font) 153e41f4b71Sopenharmony_ci 154e41f4b71Sopenharmony_ciSets the font style of the pop-up text. 155e41f4b71Sopenharmony_ci 156e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 159e41f4b71Sopenharmony_ci 160e41f4b71Sopenharmony_ci**Parameters** 161e41f4b71Sopenharmony_ci 162e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 163e41f4b71Sopenharmony_ci| ------ | ------------------------ | ---- | ------------------------------------------------------------ | 164e41f4b71Sopenharmony_ci| value | [Font](ts-types.md#font) | Yes | Font style of the pop-up text.<br>Default value:<br>{<br>size:'24.0vp',<br> style:FontStyle.Normal,<br> weight:FontWeight.Normal,<br> family:'HarmonyOS Sans'<br>} | 165e41f4b71Sopenharmony_ci 166e41f4b71Sopenharmony_ci### font 167e41f4b71Sopenharmony_ci 168e41f4b71Sopenharmony_cifont(value: Font) 169e41f4b71Sopenharmony_ci 170e41f4b71Sopenharmony_ciSets the default font style of the alphabetic index bar. 171e41f4b71Sopenharmony_ci 172e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 173e41f4b71Sopenharmony_ci 174e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 175e41f4b71Sopenharmony_ci 176e41f4b71Sopenharmony_ci**Parameters** 177e41f4b71Sopenharmony_ci 178e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 179e41f4b71Sopenharmony_ci| ------ | ------------------------ | ---- | ------------------------------------------------------------ | 180e41f4b71Sopenharmony_ci| value | [Font](ts-types.md#font) | Yes | Default font style of the alphabetic index bar.<br>Default value:<br>API version 11 and earlier:<br>{<br>size:'12.0fp',<br> style:FontStyle.Normal,<br> weight:FontWeight.Normal,<br> family:'HarmonyOS Sans'<br>}<br>API version 12 and later:<br>{<br>size:'10.0vp',<br> style:FontStyle.Normal,<br> weight:FontWeight.Medium,<br> family:'HarmonyOS Sans'<br>} | 181e41f4b71Sopenharmony_ci 182e41f4b71Sopenharmony_ci### itemSize 183e41f4b71Sopenharmony_ci 184e41f4b71Sopenharmony_ciitemSize(value: string | number) 185e41f4b71Sopenharmony_ci 186e41f4b71Sopenharmony_ciSets the size for the item in the alphabetic index bar. 187e41f4b71Sopenharmony_ci 188e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 189e41f4b71Sopenharmony_ci 190e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 191e41f4b71Sopenharmony_ci 192e41f4b71Sopenharmony_ci**Parameters** 193e41f4b71Sopenharmony_ci 194e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 195e41f4b71Sopenharmony_ci| ------ | -------------------------- | ---- | ------------------------------------------------------------ | 196e41f4b71Sopenharmony_ci| value | string \| number | Yes | Size of the item in the alphabetic index bar. The item is a square, and the side length needs to be set. This attribute cannot be set in percentage.<br>Default value: **16.0**<br>Unit: vp| 197e41f4b71Sopenharmony_ci 198e41f4b71Sopenharmony_ci### alignStyle 199e41f4b71Sopenharmony_ci 200e41f4b71Sopenharmony_cialignStyle(value: IndexerAlign, offset?: Length) 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ciSets the alignment style of the alphabetic index bar. 203e41f4b71Sopenharmony_ci 204e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 205e41f4b71Sopenharmony_ci 206e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 207e41f4b71Sopenharmony_ci 208e41f4b71Sopenharmony_ci**Parameters** 209e41f4b71Sopenharmony_ci 210e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 211e41f4b71Sopenharmony_ci| -------------------- | ------------------------------------- | ---- | ------------------------------------------------------------ | 212e41f4b71Sopenharmony_ci| value | [IndexerAlign](#indexeralign) | Yes | Alignment style of the alphabetic index bar. The pop-up window can be displayed on the right or left of the alphabetic index bar.<br>Default value: **IndexerAlign.END**| 213e41f4b71Sopenharmony_ci| offset<sup>10+</sup> | [Length](ts-types.md#length) | No | Spacing between the pop-up window and the alphabetic index bar. A value greater than or equal to **0** is valid. If this parameter is set to a value less than **0** or is not set, the spacing is the same as **popupPosition**. If this parameter and **popupPosition** are set at the same time, **offset** takes effect in the horizontal direction and **popupPosition.y** takes effect in the vertical direction.| 214e41f4b71Sopenharmony_ci 215e41f4b71Sopenharmony_ci### selected<sup>8+</sup> 216e41f4b71Sopenharmony_ci 217e41f4b71Sopenharmony_ciselected(index: number) 218e41f4b71Sopenharmony_ci 219e41f4b71Sopenharmony_ciSets the index of the selected item. 220e41f4b71Sopenharmony_ci 221e41f4b71Sopenharmony_ciSince API version 10, this attribute supports two-way binding through [$$](../../../quick-start/arkts-two-way-sync.md). 222e41f4b71Sopenharmony_ci 223e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 224e41f4b71Sopenharmony_ci 225e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 226e41f4b71Sopenharmony_ci 227e41f4b71Sopenharmony_ci**Parameters** 228e41f4b71Sopenharmony_ci 229e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 230e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------------------- | 231e41f4b71Sopenharmony_ci| index | number | Yes | Index of the selected item.<br>Default value: **0**| 232e41f4b71Sopenharmony_ci 233e41f4b71Sopenharmony_ci### popupPosition<sup>8+</sup> 234e41f4b71Sopenharmony_ci 235e41f4b71Sopenharmony_cipopupPosition(value: Position) 236e41f4b71Sopenharmony_ci 237e41f4b71Sopenharmony_ciSets the position of the pop-up window relative to the center of the indexer bar's top border. 238e41f4b71Sopenharmony_ci 239e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 240e41f4b71Sopenharmony_ci 241e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 242e41f4b71Sopenharmony_ci 243e41f4b71Sopenharmony_ci**Parameters** 244e41f4b71Sopenharmony_ci 245e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 246e41f4b71Sopenharmony_ci| ------ | --------------------------------- | ---- | ------------------------------------------------------------ | 247e41f4b71Sopenharmony_ci| value | [Position](ts-types.md#position) | Yes | Position of the pop-up window relative to the center of the indexer bar's top border.<br>Default value: **{x:60.0, y:48.0}**| 248e41f4b71Sopenharmony_ci 249e41f4b71Sopenharmony_ci### popupSelectedColor<sup>10+</sup> 250e41f4b71Sopenharmony_ci 251e41f4b71Sopenharmony_cipopupSelectedColor(value: ResourceColor) 252e41f4b71Sopenharmony_ci 253e41f4b71Sopenharmony_ciSets the color of the selected text in the non-alphabetic part in the pop-up window. 254e41f4b71Sopenharmony_ci 255e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 256e41f4b71Sopenharmony_ci 257e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 258e41f4b71Sopenharmony_ci 259e41f4b71Sopenharmony_ci**Parameters** 260e41f4b71Sopenharmony_ci 261e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 262e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ----------------------------------------------------- | 263e41f4b71Sopenharmony_ci| value | [ResourceColor](ts-types.md#resourcecolor) | Yes | Color of the selected text in the non-alphabetic part in the pop-up window.<br>Default value: **#FF182431**| 264e41f4b71Sopenharmony_ci 265e41f4b71Sopenharmony_ci### popupUnselectedColor<sup>10+</sup> 266e41f4b71Sopenharmony_ci 267e41f4b71Sopenharmony_cipopupUnselectedColor(value: ResourceColor) 268e41f4b71Sopenharmony_ci 269e41f4b71Sopenharmony_ciSets the color of the unselected text in the non-alphabetic part in the pop-up window. 270e41f4b71Sopenharmony_ci 271e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 272e41f4b71Sopenharmony_ci 273e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 274e41f4b71Sopenharmony_ci 275e41f4b71Sopenharmony_ci**Parameters** 276e41f4b71Sopenharmony_ci 277e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 278e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ------------------------------------------------------- | 279e41f4b71Sopenharmony_ci| value | [ResourceColor](ts-types.md#resourcecolor) | Yes | Color of the unselected text in the non-alphabetic part in the pop-up window.<br>Default value: **#FF182431**| 280e41f4b71Sopenharmony_ci 281e41f4b71Sopenharmony_ci### popupItemFont<sup>10+</sup> 282e41f4b71Sopenharmony_ci 283e41f4b71Sopenharmony_cipopupItemFont(value: Font) 284e41f4b71Sopenharmony_ci 285e41f4b71Sopenharmony_ciSets the font style of the non-alphabetic part in the pop-up window. 286e41f4b71Sopenharmony_ci 287e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 288e41f4b71Sopenharmony_ci 289e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 290e41f4b71Sopenharmony_ci 291e41f4b71Sopenharmony_ci**Parameters** 292e41f4b71Sopenharmony_ci 293e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 294e41f4b71Sopenharmony_ci| ------ | ------------------------ | ---- | ------------------------------------------------------------ | 295e41f4b71Sopenharmony_ci| value | [Font](ts-types.md#font) | Yes | Font style of the non-alphabetic part in the pop-up window.<br>Default value:<br>{<br>size:24,<br>weight:FontWeight.Medium<br>} | 296e41f4b71Sopenharmony_ci 297e41f4b71Sopenharmony_ci### popupItemBackgroundColor<sup>10+</sup> 298e41f4b71Sopenharmony_ci 299e41f4b71Sopenharmony_cipopupItemBackgroundColor(value: ResourceColor) 300e41f4b71Sopenharmony_ci 301e41f4b71Sopenharmony_ciSets the background color of the non-alphabetic part in the pop-up window. 302e41f4b71Sopenharmony_ci 303e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 304e41f4b71Sopenharmony_ci 305e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 306e41f4b71Sopenharmony_ci 307e41f4b71Sopenharmony_ci**Parameters** 308e41f4b71Sopenharmony_ci 309e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 310e41f4b71Sopenharmony_ci| ------ | ------------------------ | ---- | ----------------------------------------------- | 311e41f4b71Sopenharmony_ci| value | [ResourceColor](ts-types.md#resourcecolor) | Yes | Background color of the non-alphabetic part in the pop-up window.<br>Default value:<br>API version 11 and earlier: **#FFFFFFFF**<br>API version 12 and later: **#00000000**| 312e41f4b71Sopenharmony_ci 313e41f4b71Sopenharmony_ci### autoCollapse<sup>11+</sup> 314e41f4b71Sopenharmony_ci 315e41f4b71Sopenharmony_ciautoCollapse(value: boolean) 316e41f4b71Sopenharmony_ci 317e41f4b71Sopenharmony_ciSets whether to auto-collapse or expand the indexer bar. 318e41f4b71Sopenharmony_ci 319e41f4b71Sopenharmony_ciIf the initial character is **#**, it is excluded. Number of remaining characters $\leq$ 9: The index bar is expanded. 9 < Number of remaining characters $\leq$ 13: The index bar is expanded or partially collapsed, depending on its height. Number of remaining characters > 13: The index bar is fully or partially collapsed, depending on its height. 320e41f4b71Sopenharmony_ci 321e41f4b71Sopenharmony_ciIf the initial character is not **#**: Number of all characters $\leq$ 9: The index bar is expanded. 9 < Number of all characters $\leq$ 13: The index bar is expanded or partially collapsed, depending on its height. Number of all characters > 13: The index bar is fully or partially collapsed, depending on its height. 322e41f4b71Sopenharmony_ci 323e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 324e41f4b71Sopenharmony_ci 325e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 326e41f4b71Sopenharmony_ci 327e41f4b71Sopenharmony_ci**Parameters** 328e41f4b71Sopenharmony_ci 329e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 330e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ------------------------------------------ | 331e41f4b71Sopenharmony_ci| value | boolean | Yes | Whether to auto-collapse or expand the indexer bar.<br>Default value:<br>In versions earlier than API version 12: **false**<br>API version 12 and later: **true**| 332e41f4b71Sopenharmony_ci 333e41f4b71Sopenharmony_ci### popupItemBorderRadius<sup>12+</sup> 334e41f4b71Sopenharmony_ci 335e41f4b71Sopenharmony_cipopupItemBorderRadius(value: number) 336e41f4b71Sopenharmony_ci 337e41f4b71Sopenharmony_ciSets the radius of the index border corners in the pop-up window. 338e41f4b71Sopenharmony_ci 339e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 340e41f4b71Sopenharmony_ci 341e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 342e41f4b71Sopenharmony_ci 343e41f4b71Sopenharmony_ci**Parameters** 344e41f4b71Sopenharmony_ci 345e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 346e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------------------------------------------------ | 347e41f4b71Sopenharmony_ci| value | number | Yes | Radius of the index background border corners in the pop-up window.<br>Default value: **24vp**<br>This parameter cannot be set in percentage. If the value specified is less than **0**, **0** is used.<br>The radius of the index background border corners in the pop-up window is automatically adaptive (radius of the index rounded corners + 4 vp).| 348e41f4b71Sopenharmony_ci 349e41f4b71Sopenharmony_ci### itemBorderRadius<sup>12+</sup> 350e41f4b71Sopenharmony_ci 351e41f4b71Sopenharmony_ciitemBorderRadius(value: number) 352e41f4b71Sopenharmony_ci 353e41f4b71Sopenharmony_ciSets the radius of the index background border corners in the alphabetic index bar. 354e41f4b71Sopenharmony_ci 355e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 356e41f4b71Sopenharmony_ci 357e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 358e41f4b71Sopenharmony_ci 359e41f4b71Sopenharmony_ci**Parameters** 360e41f4b71Sopenharmony_ci 361e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 362e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------------------------------------------------ | 363e41f4b71Sopenharmony_ci| value | number | Yes | Radius of the index background border corners in the alphabetic index bar.<br>Default value: **8vp**<br>This parameter cannot be set in percentage. If the value specified is less than **0**, **0** is used.<br>The radius of the index background border corners in the alphabetic index bar is automatically adaptive (radius of the index rounded corners + 4 vp).| 364e41f4b71Sopenharmony_ci 365e41f4b71Sopenharmony_ci### popupBackgroundBlurStyle<sup>12+</sup> 366e41f4b71Sopenharmony_ci 367e41f4b71Sopenharmony_cipopupBackgroundBlurStyle(value: BlurStyle) 368e41f4b71Sopenharmony_ci 369e41f4b71Sopenharmony_ciSets the background blur style of the pop-up window. 370e41f4b71Sopenharmony_ci 371e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 372e41f4b71Sopenharmony_ci 373e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 374e41f4b71Sopenharmony_ci 375e41f4b71Sopenharmony_ci**Parameters** 376e41f4b71Sopenharmony_ci 377e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 378e41f4b71Sopenharmony_ci| ------ | -------------------------------------------- | ---- | ------------------------------------------------------------ | 379e41f4b71Sopenharmony_ci| value | [BlurStyle](ts-universal-attributes-background.md#blurstyle9) | Yes | Background blur style of the pop-up window.<br>Default value: **COMPONENT_REGULAR**| 380e41f4b71Sopenharmony_ci 381e41f4b71Sopenharmony_ci### popupTitleBackground<sup>12+</sup> 382e41f4b71Sopenharmony_ci 383e41f4b71Sopenharmony_cipopupTitleBackground(value: ResourceColor) 384e41f4b71Sopenharmony_ci 385e41f4b71Sopenharmony_ciSets the background color of the first index in the pop-up window. 386e41f4b71Sopenharmony_ci 387e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 388e41f4b71Sopenharmony_ci 389e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 390e41f4b71Sopenharmony_ci 391e41f4b71Sopenharmony_ci**Parameters** 392e41f4b71Sopenharmony_ci 393e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 394e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ------------------------------------------------------------ | 395e41f4b71Sopenharmony_ci| value | [ResourceColor](ts-types.md#resourcecolor) | Yes | Background color of the first index in the pop-up window.<br>Default value:<br>If the pop-up window has only one index: **#00FFFFFF**.<br>If the pop-up window has multiple indexes: **#0c182431**.| 396e41f4b71Sopenharmony_ci 397e41f4b71Sopenharmony_ci### enableHapticFeedback<sup>12+</sup> 398e41f4b71Sopenharmony_ci 399e41f4b71Sopenharmony_cienableHapticFeedback(value: boolean) 400e41f4b71Sopenharmony_ci 401e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 402e41f4b71Sopenharmony_ci 403e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 404e41f4b71Sopenharmony_ci 405e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 406e41f4b71Sopenharmony_ci|-------------|-----------------------------------------------------|----|----------------------------| 407e41f4b71Sopenharmony_ci| value | boolean | No | Whether haptic feedback is enabled.<br>Default value: **true**<br>| 408e41f4b71Sopenharmony_ci 409e41f4b71Sopenharmony_ci## IndexerAlign 410e41f4b71Sopenharmony_ci 411e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 412e41f4b71Sopenharmony_ci 413e41f4b71Sopenharmony_ci| Name| Description| 414e41f4b71Sopenharmony_ci| -------- | -------- | 415e41f4b71Sopenharmony_ci| Left | The pop-up window is displayed on the right of the alphabetic indexer bar.<br>**Atomic service API**: This API can be used in atomic services since API version 11.| 416e41f4b71Sopenharmony_ci| Right | The pop-up window is displayed on the left of the alphabetic indexer bar.<br>**Atomic service API**: This API can be used in atomic services since API version 11.| 417e41f4b71Sopenharmony_ci| START<sup>12+</sup> | The pop-up window is displayed on the right of the alphabetic indexer bar for left-to-right scripts, and on the left of the alphabetic indexer bar for right-to-left scripts.<br>**Atomic service API**: This API can be used in atomic services since API version 12.| 418e41f4b71Sopenharmony_ci| END<sup>12+</sup> | The pop-up window is displayed on the left of the alphabetic indexer bar for left-to-right scripts, and on the right of the alphabetic indexer bar for right-to-left scripts.<br>**Atomic service API**: This API can be used in atomic services since API version 12.| 419e41f4b71Sopenharmony_ci 420e41f4b71Sopenharmony_ci## Events 421e41f4b71Sopenharmony_ci 422e41f4b71Sopenharmony_ciIn addition to the [universal events](ts-universal-events-click.md), the following events are supported. 423e41f4b71Sopenharmony_ci 424e41f4b71Sopenharmony_ci### onSelected<sup>(deprecated)</sup> 425e41f4b71Sopenharmony_ci 426e41f4b71Sopenharmony_cionSelected(callback: (index: number) => void) 427e41f4b71Sopenharmony_ci 428e41f4b71Sopenharmony_ciInvoked when an item in the alphabetic indexer bar is selected. The return value is the index of the selected item. 429e41f4b71Sopenharmony_ci 430e41f4b71Sopenharmony_ciThis API is deprecated since API version 8. You are advised to use [onSelect](#onselect8) instead. 431e41f4b71Sopenharmony_ci 432e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 433e41f4b71Sopenharmony_ci 434e41f4b71Sopenharmony_ci**Parameters** 435e41f4b71Sopenharmony_ci 436e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 437e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------- | 438e41f4b71Sopenharmony_ci| index | number | Yes | Index of the selected item.| 439e41f4b71Sopenharmony_ci 440e41f4b71Sopenharmony_ci### onSelect<sup>8+</sup> 441e41f4b71Sopenharmony_ci 442e41f4b71Sopenharmony_cionSelect(callback: (index: number) => void) 443e41f4b71Sopenharmony_ci 444e41f4b71Sopenharmony_ciInvoked when an item in the alphabetic indexer bar is selected. The return value is the index of the selected item. 445e41f4b71Sopenharmony_ci 446e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 447e41f4b71Sopenharmony_ci 448e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 449e41f4b71Sopenharmony_ci 450e41f4b71Sopenharmony_ci**Parameters** 451e41f4b71Sopenharmony_ci 452e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 453e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------- | 454e41f4b71Sopenharmony_ci| index | number | Yes | Index of the selected item.| 455e41f4b71Sopenharmony_ci 456e41f4b71Sopenharmony_ci### onRequestPopupData<sup>8+</sup> 457e41f4b71Sopenharmony_ci 458e41f4b71Sopenharmony_cionRequestPopupData(callback: (index: number) => Array<string>) 459e41f4b71Sopenharmony_ci 460e41f4b71Sopenharmony_ciInvoked when a request for displaying content in the index pop-up window is sent after an item in the alphabetic indexer bar is selected. 461e41f4b71Sopenharmony_ci 462e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 463e41f4b71Sopenharmony_ci 464e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 465e41f4b71Sopenharmony_ci 466e41f4b71Sopenharmony_ci**Parameters** 467e41f4b71Sopenharmony_ci 468e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 469e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------------------------------------------------ | 470e41f4b71Sopenharmony_ci| index | number | Yes | Index of the selected item.| 471e41f4b71Sopenharmony_ci 472e41f4b71Sopenharmony_ci**Return value** 473e41f4b71Sopenharmony_ci 474e41f4b71Sopenharmony_ci| Type | Description | 475e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | 476e41f4b71Sopenharmony_ci| Array<string> | String array corresponding to the selected index. The string array is displayed vertically in the pop-up window. It can display up to five strings at once and allows scrolling.| 477e41f4b71Sopenharmony_ci 478e41f4b71Sopenharmony_ci### onPopupSelect<sup>8+</sup> 479e41f4b71Sopenharmony_ci 480e41f4b71Sopenharmony_cionPopupSelect(callback: (index: number) => void) 481e41f4b71Sopenharmony_ci 482e41f4b71Sopenharmony_ciInvoked when an item in the index pop-up window is selected. 483e41f4b71Sopenharmony_ci 484e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 485e41f4b71Sopenharmony_ci 486e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 487e41f4b71Sopenharmony_ci 488e41f4b71Sopenharmony_ci**Parameters** 489e41f4b71Sopenharmony_ci 490e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 491e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------- | 492e41f4b71Sopenharmony_ci| index | number | Yes | Index of the selected item.| 493e41f4b71Sopenharmony_ci 494e41f4b71Sopenharmony_ci 495e41f4b71Sopenharmony_ci## Example 496e41f4b71Sopenharmony_ci### Example 1 497e41f4b71Sopenharmony_ci 498e41f4b71Sopenharmony_ci```ts 499e41f4b71Sopenharmony_ci// xxx.ets 500e41f4b71Sopenharmony_ci@Entry 501e41f4b71Sopenharmony_ci@Component 502e41f4b71Sopenharmony_cistruct AlphabetIndexerSample { 503e41f4b71Sopenharmony_ci private arrayA:string[] = ['Ann'] 504e41f4b71Sopenharmony_ci private arrayB: string[] = ['Ben', 'Bob'] 505e41f4b71Sopenharmony_ci private arrayC: string[] = ['Calvin', 'Cameron', 'Charlie', 'Charlotte'] 506e41f4b71Sopenharmony_ci private arrayL: string[] = ['Daisy', 'Daniel', 'Darla', 'David', 'Derek', 'Dorothy', 'Duke'] 507e41f4b71Sopenharmony_ci private value: string[] = ['#', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 508e41f4b71Sopenharmony_ci 'H', 'I', 'J', 'K', 'L', 'M', 'N', 509e41f4b71Sopenharmony_ci 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 510e41f4b71Sopenharmony_ci 'V', 'W', 'X', 'Y', 'Z'] 511e41f4b71Sopenharmony_ci 512e41f4b71Sopenharmony_ci build() { 513e41f4b71Sopenharmony_ci Stack({ alignContent: Alignment.Start }) { 514e41f4b71Sopenharmony_ci Row() { 515e41f4b71Sopenharmony_ci List({ space: 20, initialIndex: 0 }) { 516e41f4b71Sopenharmony_ci ForEach(this.arrayA, (item: string) => { 517e41f4b71Sopenharmony_ci ListItem() { 518e41f4b71Sopenharmony_ci Text(item) 519e41f4b71Sopenharmony_ci .width('80%') 520e41f4b71Sopenharmony_ci .height('5%') 521e41f4b71Sopenharmony_ci .fontSize(30) 522e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 523e41f4b71Sopenharmony_ci } 524e41f4b71Sopenharmony_ci }, (item: string) => item) 525e41f4b71Sopenharmony_ci 526e41f4b71Sopenharmony_ci ForEach(this.arrayB, (item: string) => { 527e41f4b71Sopenharmony_ci ListItem() { 528e41f4b71Sopenharmony_ci Text(item) 529e41f4b71Sopenharmony_ci .width('80%') 530e41f4b71Sopenharmony_ci .height('5%') 531e41f4b71Sopenharmony_ci .fontSize(30) 532e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 533e41f4b71Sopenharmony_ci } 534e41f4b71Sopenharmony_ci }, (item: string) => item) 535e41f4b71Sopenharmony_ci 536e41f4b71Sopenharmony_ci ForEach(this.arrayC, (item: string) => { 537e41f4b71Sopenharmony_ci ListItem() { 538e41f4b71Sopenharmony_ci Text(item) 539e41f4b71Sopenharmony_ci .width('80%') 540e41f4b71Sopenharmony_ci .height('5%') 541e41f4b71Sopenharmony_ci .fontSize(30) 542e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 543e41f4b71Sopenharmony_ci } 544e41f4b71Sopenharmony_ci }, (item: string) => item) 545e41f4b71Sopenharmony_ci 546e41f4b71Sopenharmony_ci ForEach(this.arrayL, (item: string) => { 547e41f4b71Sopenharmony_ci ListItem() { 548e41f4b71Sopenharmony_ci Text(item) 549e41f4b71Sopenharmony_ci .width('80%') 550e41f4b71Sopenharmony_ci .height('5%') 551e41f4b71Sopenharmony_ci .fontSize(30) 552e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 553e41f4b71Sopenharmony_ci } 554e41f4b71Sopenharmony_ci }, (item: string) => item) 555e41f4b71Sopenharmony_ci } 556e41f4b71Sopenharmony_ci .width('50%') 557e41f4b71Sopenharmony_ci .height('100%') 558e41f4b71Sopenharmony_ci 559e41f4b71Sopenharmony_ci AlphabetIndexer({ arrayValue: this.value, selected: 0 }) 560e41f4b71Sopenharmony_ci .autoCollapse(false) 561e41f4b71Sopenharmony_ci .selectedColor(0xFFFFFF) // Font color of the selected text. 562e41f4b71Sopenharmony_ci .popupColor(0xFFFAF0) // Font color of the pop-up text. 563e41f4b71Sopenharmony_ci .selectedBackgroundColor(0xCCCCCC) // Background color of the selected item. 564e41f4b71Sopenharmony_ci .popupBackground(0xD2B48C) // Background color of the pop-up text. 565e41f4b71Sopenharmony_ci .usingPopup(true) // Whether to use pop-up text. 566e41f4b71Sopenharmony_ci .selectedFont({size: 16, weight: FontWeight.Bolder}) // Font style of the selected text. 567e41f4b71Sopenharmony_ci .popupFont({ size: 30, weight: FontWeight.Bolder}) // Font style of the pop-up text. 568e41f4b71Sopenharmony_ci .itemSize(28) // Size of an item in the alphabetic index bar. 569e41f4b71Sopenharmony_ci .alignStyle(IndexerAlign.Left) // The pop-up window is displayed on the right of the alphabetic index bar. 570e41f4b71Sopenharmony_ci .popupItemBorderRadius(24) // Set the radius of the index background rounded corners in the pop-up window. 571e41f4b71Sopenharmony_ci .itemBorderRadius(14) // Set the radius of the index background rounded corners in the alphabetic indexer bar. 572e41f4b71Sopenharmony_ci .popupBackgroundBlurStyle(BlurStyle.NONE) // Set the background blur style of the pop-up window. 573e41f4b71Sopenharmony_ci .popupTitleBackground(0xCCCCCC) // Set the background color of the first index in the pop-up window. 574e41f4b71Sopenharmony_ci .popupSelectedColor(0x00FF00) 575e41f4b71Sopenharmony_ci .popupUnselectedColor(0x0000FF) 576e41f4b71Sopenharmony_ci .popupItemFont({ size: 30, style: FontStyle.Normal }) 577e41f4b71Sopenharmony_ci .popupItemBackgroundColor(0xCCCCCC) 578e41f4b71Sopenharmony_ci .onSelect((index: number) => { 579e41f4b71Sopenharmony_ci console.info(this.value[index] + ' Selected!') 580e41f4b71Sopenharmony_ci }) 581e41f4b71Sopenharmony_ci .onRequestPopupData((index: number) => { 582e41f4b71Sopenharmony_ci if (this.value[index] == 'A') { 583e41f4b71Sopenharmony_ci return this.arrayA // When index A is selected, the pop-up window displays arrayA corresponding to index A. The same applies when other indexes are selected. 584e41f4b71Sopenharmony_ci } else if (this.value[index] == 'B') { 585e41f4b71Sopenharmony_ci return this.arrayB 586e41f4b71Sopenharmony_ci } else if (this.value[index] == 'C') { 587e41f4b71Sopenharmony_ci return this.arrayC 588e41f4b71Sopenharmony_ci } else if (this.value[index] == 'L') { 589e41f4b71Sopenharmony_ci return this.arrayL 590e41f4b71Sopenharmony_ci } else { 591e41f4b71Sopenharmony_ci return [] // When no array is available for the selected index, the pop-up window is empty. 592e41f4b71Sopenharmony_ci } 593e41f4b71Sopenharmony_ci }) 594e41f4b71Sopenharmony_ci .onPopupSelect((index: number) => { 595e41f4b71Sopenharmony_ci console.info('onPopupSelected:' + index) 596e41f4b71Sopenharmony_ci }) 597e41f4b71Sopenharmony_ci } 598e41f4b71Sopenharmony_ci .width('100%') 599e41f4b71Sopenharmony_ci .height('100%') 600e41f4b71Sopenharmony_ci } 601e41f4b71Sopenharmony_ci } 602e41f4b71Sopenharmony_ci} 603e41f4b71Sopenharmony_ci``` 604e41f4b71Sopenharmony_ci 605e41f4b71Sopenharmony_ci 606e41f4b71Sopenharmony_ci 607e41f4b71Sopenharmony_ci### Example 2 608e41f4b71Sopenharmony_ci```ts 609e41f4b71Sopenharmony_ci// xxx.ets 610e41f4b71Sopenharmony_ci@Entry 611e41f4b71Sopenharmony_ci@Component 612e41f4b71Sopenharmony_cistruct AlphabetIndexerSample { 613e41f4b71Sopenharmony_ci private arrayA:string[] = ['Ann'] 614e41f4b71Sopenharmony_ci private arrayB: string[] = ['Ben', 'Bob'] 615e41f4b71Sopenharmony_ci private arrayC: string[] = ['Calvin', 'Cameron', 'Charlie', 'Charlotte'] 616e41f4b71Sopenharmony_ci private arrayJ: string[] = ['Jack', 'James'] 617e41f4b71Sopenharmony_ci private value: string[] = ['#', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 618e41f4b71Sopenharmony_ci 'H', 'I', 'J', 'K', 'L', 'M', 'N', 619e41f4b71Sopenharmony_ci 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 620e41f4b71Sopenharmony_ci 'V', 'W', 'X', 'Y', 'Z'] 621e41f4b71Sopenharmony_ci @State isNeedAutoCollapse: boolean = false; 622e41f4b71Sopenharmony_ci @State indexerHeight: string = '75%'; 623e41f4b71Sopenharmony_ci 624e41f4b71Sopenharmony_ci build() { 625e41f4b71Sopenharmony_ci Stack({ alignContent: Alignment.Start }) { 626e41f4b71Sopenharmony_ci Row() { 627e41f4b71Sopenharmony_ci List({ space: 20, initialIndex: 0 }) { 628e41f4b71Sopenharmony_ci ForEach(this.arrayA, (item: string) => { 629e41f4b71Sopenharmony_ci ListItem() { 630e41f4b71Sopenharmony_ci Text(item) 631e41f4b71Sopenharmony_ci .width('80%') 632e41f4b71Sopenharmony_ci .height('5%') 633e41f4b71Sopenharmony_ci .fontSize(30) 634e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 635e41f4b71Sopenharmony_ci } 636e41f4b71Sopenharmony_ci }, (item: string) => item) 637e41f4b71Sopenharmony_ci 638e41f4b71Sopenharmony_ci ForEach(this.arrayB, (item: string) => { 639e41f4b71Sopenharmony_ci ListItem() { 640e41f4b71Sopenharmony_ci Text(item) 641e41f4b71Sopenharmony_ci .width('80%') 642e41f4b71Sopenharmony_ci .height('5%') 643e41f4b71Sopenharmony_ci .fontSize(30) 644e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 645e41f4b71Sopenharmony_ci } 646e41f4b71Sopenharmony_ci }, (item: string) => item) 647e41f4b71Sopenharmony_ci 648e41f4b71Sopenharmony_ci ForEach(this.arrayC, (item: string) => { 649e41f4b71Sopenharmony_ci ListItem() { 650e41f4b71Sopenharmony_ci Text(item) 651e41f4b71Sopenharmony_ci .width('80%') 652e41f4b71Sopenharmony_ci .height('5%') 653e41f4b71Sopenharmony_ci .fontSize(30) 654e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 655e41f4b71Sopenharmony_ci } 656e41f4b71Sopenharmony_ci }, (item: string) => item) 657e41f4b71Sopenharmony_ci 658e41f4b71Sopenharmony_ci ForEach(this.arrayJ, (item: string) => { 659e41f4b71Sopenharmony_ci ListItem() { 660e41f4b71Sopenharmony_ci Text(item) 661e41f4b71Sopenharmony_ci .width('80%') 662e41f4b71Sopenharmony_ci .height('5%') 663e41f4b71Sopenharmony_ci .fontSize(30) 664e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 665e41f4b71Sopenharmony_ci } 666e41f4b71Sopenharmony_ci }, (item: string) => item) 667e41f4b71Sopenharmony_ci } 668e41f4b71Sopenharmony_ci .width('50%') 669e41f4b71Sopenharmony_ci .height('100%') 670e41f4b71Sopenharmony_ci 671e41f4b71Sopenharmony_ci Column() { 672e41f4b71Sopenharmony_ci Column() { 673e41f4b71Sopenharmony_ci AlphabetIndexer({ arrayValue: this.value, selected: 0 }) 674e41f4b71Sopenharmony_ci .autoCollapse(this.isNeedAutoCollapse) 675e41f4b71Sopenharmony_ci .height(this.indexerHeight) 676e41f4b71Sopenharmony_ci .selectedColor(0xFFFFFF)// Font color of the selected item. 677e41f4b71Sopenharmony_ci .popupColor(0xFFFAF0)// Font color of the pop-up text. 678e41f4b71Sopenharmony_ci .selectedBackgroundColor(0xCCCCCC)// Background color of the selected item. 679e41f4b71Sopenharmony_ci .popupBackground(0xD2B48C)// Background color of the pop-up text. 680e41f4b71Sopenharmony_ci .usingPopup(true)// Whether to use pop-up text. 681e41f4b71Sopenharmony_ci .selectedFont({size: 16, weight: FontWeight.Bolder})// Font style of the selected item. 682e41f4b71Sopenharmony_ci .popupFont({ size: 30, weight: FontWeight.Bolder})// Font style of the pop-up text. 683e41f4b71Sopenharmony_ci .itemSize(28)// Size of an item in the alphabetic index bar. 684e41f4b71Sopenharmony_ci .alignStyle(IndexerAlign.Right)// The pop-up window is displayed on the left of the alphabetic index bar. 685e41f4b71Sopenharmony_ci .popupTitleBackground("#D2B48C") // Background color of the first index in the pop-up window. 686e41f4b71Sopenharmony_ci .popupSelectedColor(0x00FF00) 687e41f4b71Sopenharmony_ci .popupUnselectedColor(0x0000FF) 688e41f4b71Sopenharmony_ci .popupItemFont({ size: 30, style: FontStyle.Normal }) 689e41f4b71Sopenharmony_ci .popupItemBackgroundColor(0xCCCCCC) 690e41f4b71Sopenharmony_ci .onSelect((index: number) => { 691e41f4b71Sopenharmony_ci console.info(this.value[index] + ' Selected!'); 692e41f4b71Sopenharmony_ci }) 693e41f4b71Sopenharmony_ci .onRequestPopupData((index: number) => { 694e41f4b71Sopenharmony_ci if (this.value[index] == 'A') { 695e41f4b71Sopenharmony_ci return this.arrayA; 696e41f4b71Sopenharmony_ci } else if (this.value[index] == 'B') { 697e41f4b71Sopenharmony_ci return this.arrayB; 698e41f4b71Sopenharmony_ci } else if (this.value[index] == 'C') { 699e41f4b71Sopenharmony_ci return this.arrayC; 700e41f4b71Sopenharmony_ci } else if (this.value[index] == 'J') { 701e41f4b71Sopenharmony_ci return this.arrayJ; 702e41f4b71Sopenharmony_ci } else { 703e41f4b71Sopenharmony_ci return []; 704e41f4b71Sopenharmony_ci } 705e41f4b71Sopenharmony_ci }) 706e41f4b71Sopenharmony_ci .onPopupSelect((index: number) => { 707e41f4b71Sopenharmony_ci console.info('onPopupSelected:' + index); 708e41f4b71Sopenharmony_ci }) 709e41f4b71Sopenharmony_ci } 710e41f4b71Sopenharmony_ci .height('80%') 711e41f4b71Sopenharmony_ci .justifyContent(FlexAlign.Center) 712e41f4b71Sopenharmony_ci 713e41f4b71Sopenharmony_ci Column() { 714e41f4b71Sopenharmony_ci Button ('Collapse') 715e41f4b71Sopenharmony_ci .margin('5vp') 716e41f4b71Sopenharmony_ci .onClick(() => { 717e41f4b71Sopenharmony_ci this.isNeedAutoCollapse = true; 718e41f4b71Sopenharmony_ci }) 719e41f4b71Sopenharmony_ci Button ('30% of Index Bar Height') 720e41f4b71Sopenharmony_ci .margin('5vp') 721e41f4b71Sopenharmony_ci .onClick(() => { 722e41f4b71Sopenharmony_ci this.indexerHeight = '30%'; 723e41f4b71Sopenharmony_ci }) 724e41f4b71Sopenharmony_ci Button ('70% of Index Bar Height') 725e41f4b71Sopenharmony_ci .margin('5vp') 726e41f4b71Sopenharmony_ci .onClick(() => { 727e41f4b71Sopenharmony_ci this.indexerHeight = '70%'; 728e41f4b71Sopenharmony_ci }) 729e41f4b71Sopenharmony_ci }.height('20%') 730e41f4b71Sopenharmony_ci } 731e41f4b71Sopenharmony_ci .width('50%') 732e41f4b71Sopenharmony_ci .justifyContent(FlexAlign.Center) 733e41f4b71Sopenharmony_ci } 734e41f4b71Sopenharmony_ci .width('100%') 735e41f4b71Sopenharmony_ci .height('100%') 736e41f4b71Sopenharmony_ci } 737e41f4b71Sopenharmony_ci } 738e41f4b71Sopenharmony_ci} 739e41f4b71Sopenharmony_ci``` 740e41f4b71Sopenharmony_ci 741e41f4b71Sopenharmony_ci 742e41f4b71Sopenharmony_ci 743e41f4b71Sopenharmony_ci### Example 3 744e41f4b71Sopenharmony_ci 745e41f4b71Sopenharmony_ci```ts 746e41f4b71Sopenharmony_ci// This example implements a pop-up window in the custom background blur style. 747e41f4b71Sopenharmony_ci@Entry 748e41f4b71Sopenharmony_ci@Component 749e41f4b71Sopenharmony_cistruct AlphabetIndexerSample { 750e41f4b71Sopenharmony_ci private arrayA:string[] = ['Ann'] 751e41f4b71Sopenharmony_ci private arrayB: string[] = ['Ben', 'Bob'] 752e41f4b71Sopenharmony_ci private arrayC: string[] = ['Calvin', 'Cameron', 'Charlie', 'Charlotte'] 753e41f4b71Sopenharmony_ci private arrayL: string[] = ['Daisy', 'Daniel', 'Darla', 'David', 'Derek', 'Dorothy', 'Duke'] 754e41f4b71Sopenharmony_ci private value: string[] = ['#', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 755e41f4b71Sopenharmony_ci 'H', 'I', 'J', 'K', 'L', 'M', 'N', 756e41f4b71Sopenharmony_ci 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 757e41f4b71Sopenharmony_ci 'V', 'W', 'X', 'Y', 'Z'] 758e41f4b71Sopenharmony_ci @State customBlurStyle: BlurStyle = BlurStyle.NONE; 759e41f4b71Sopenharmony_ci 760e41f4b71Sopenharmony_ci build() { 761e41f4b71Sopenharmony_ci Stack({ alignContent: Alignment.Start }) { 762e41f4b71Sopenharmony_ci Row() { 763e41f4b71Sopenharmony_ci List({ space: 20, initialIndex: 0 }) { 764e41f4b71Sopenharmony_ci ForEach(this.arrayA, (item: string) => { 765e41f4b71Sopenharmony_ci ListItem() { 766e41f4b71Sopenharmony_ci Text(item) 767e41f4b71Sopenharmony_ci .width('80%') 768e41f4b71Sopenharmony_ci .height('5%') 769e41f4b71Sopenharmony_ci .fontSize(30) 770e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 771e41f4b71Sopenharmony_ci } 772e41f4b71Sopenharmony_ci }, (item: string) => item) 773e41f4b71Sopenharmony_ci 774e41f4b71Sopenharmony_ci ForEach(this.arrayB, (item: string) => { 775e41f4b71Sopenharmony_ci ListItem() { 776e41f4b71Sopenharmony_ci Text(item) 777e41f4b71Sopenharmony_ci .width('80%') 778e41f4b71Sopenharmony_ci .height('5%') 779e41f4b71Sopenharmony_ci .fontSize(30) 780e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 781e41f4b71Sopenharmony_ci } 782e41f4b71Sopenharmony_ci }, (item: string) => item) 783e41f4b71Sopenharmony_ci 784e41f4b71Sopenharmony_ci ForEach(this.arrayC, (item: string) => { 785e41f4b71Sopenharmony_ci ListItem() { 786e41f4b71Sopenharmony_ci Text(item) 787e41f4b71Sopenharmony_ci .width('80%') 788e41f4b71Sopenharmony_ci .height('5%') 789e41f4b71Sopenharmony_ci .fontSize(30) 790e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 791e41f4b71Sopenharmony_ci } 792e41f4b71Sopenharmony_ci }, (item: string) => item) 793e41f4b71Sopenharmony_ci 794e41f4b71Sopenharmony_ci ForEach(this.arrayL, (item: string) => { 795e41f4b71Sopenharmony_ci ListItem() { 796e41f4b71Sopenharmony_ci Text(item) 797e41f4b71Sopenharmony_ci .width('80%') 798e41f4b71Sopenharmony_ci .height('5%') 799e41f4b71Sopenharmony_ci .fontSize(30) 800e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 801e41f4b71Sopenharmony_ci } 802e41f4b71Sopenharmony_ci }, (item: string) => item) 803e41f4b71Sopenharmony_ci } 804e41f4b71Sopenharmony_ci .width('30%') 805e41f4b71Sopenharmony_ci .height('100%') 806e41f4b71Sopenharmony_ci Column(){ 807e41f4b71Sopenharmony_ci Column() { 808e41f4b71Sopenharmony_ci Text('Switch Blue Style:') 809e41f4b71Sopenharmony_ci .fontSize(24) 810e41f4b71Sopenharmony_ci .fontColor(0xcccccc) 811e41f4b71Sopenharmony_ci .width('100%') 812e41f4b71Sopenharmony_ci Button('COMPONENT_REGULAR') 813e41f4b71Sopenharmony_ci .margin('5vp') 814e41f4b71Sopenharmony_ci .width(200) 815e41f4b71Sopenharmony_ci .onClick(() => { 816e41f4b71Sopenharmony_ci this.customBlurStyle = BlurStyle.COMPONENT_REGULAR; 817e41f4b71Sopenharmony_ci }) 818e41f4b71Sopenharmony_ci Button('BACKGROUND_THIN') 819e41f4b71Sopenharmony_ci .margin('5vp') 820e41f4b71Sopenharmony_ci .width(200) 821e41f4b71Sopenharmony_ci .onClick(() => { 822e41f4b71Sopenharmony_ci this.customBlurStyle = BlurStyle.BACKGROUND_THIN; 823e41f4b71Sopenharmony_ci }) 824e41f4b71Sopenharmony_ci }.height('20%') 825e41f4b71Sopenharmony_ci 826e41f4b71Sopenharmony_ci Column(){ 827e41f4b71Sopenharmony_ci AlphabetIndexer({ arrayValue: this.value, selected: 0 }) 828e41f4b71Sopenharmony_ci .usingPopup(true) // Whether to use pop-up text. 829e41f4b71Sopenharmony_ci .alignStyle(IndexerAlign.Left) // The pop-up window is displayed on the right of the alphabetic index bar. 830e41f4b71Sopenharmony_ci .popupItemBorderRadius(24) // Set the radius of the index background rounded corners in the pop-up window. 831e41f4b71Sopenharmony_ci .itemBorderRadius(14) // Set the radius of the index background rounded corners in the alphabetic indexer bar. 832e41f4b71Sopenharmony_ci .popupBackgroundBlurStyle(this.customBlurStyle) // Set the background blur style of the pop-up window. 833e41f4b71Sopenharmony_ci .popupTitleBackground(0xCCCCCC) // Set the background color of the first index in the pop-up window. 834e41f4b71Sopenharmony_ci .onSelect((index: number) => { 835e41f4b71Sopenharmony_ci console.info(this.value[index] + ' Selected!') 836e41f4b71Sopenharmony_ci }) 837e41f4b71Sopenharmony_ci .onRequestPopupData((index: number) => { 838e41f4b71Sopenharmony_ci if (this.value[index] == 'A') { 839e41f4b71Sopenharmony_ci return this.arrayA // When index A is selected, the pop-up window displays arrayA corresponding to index A. The same applies when other indexes are selected. 840e41f4b71Sopenharmony_ci } else if (this.value[index] == 'B') { 841e41f4b71Sopenharmony_ci return this.arrayB 842e41f4b71Sopenharmony_ci } else if (this.value[index] == 'C') { 843e41f4b71Sopenharmony_ci return this.arrayC 844e41f4b71Sopenharmony_ci } else if (this.value[index] == 'L') { 845e41f4b71Sopenharmony_ci return this.arrayL 846e41f4b71Sopenharmony_ci } else { 847e41f4b71Sopenharmony_ci return [] // When no array is available for the selected index, the pop-up window is empty. 848e41f4b71Sopenharmony_ci } 849e41f4b71Sopenharmony_ci }) 850e41f4b71Sopenharmony_ci .onPopupSelect((index: number) => { 851e41f4b71Sopenharmony_ci console.info('onPopupSelected:' + index) 852e41f4b71Sopenharmony_ci }) 853e41f4b71Sopenharmony_ci } 854e41f4b71Sopenharmony_ci .height('80%') 855e41f4b71Sopenharmony_ci } 856e41f4b71Sopenharmony_ci .width('70%') 857e41f4b71Sopenharmony_ci } 858e41f4b71Sopenharmony_ci .width('100%') 859e41f4b71Sopenharmony_ci .height('100%') 860e41f4b71Sopenharmony_ci .backgroundImage($r("app.media.image")) 861e41f4b71Sopenharmony_ci } 862e41f4b71Sopenharmony_ci } 863e41f4b71Sopenharmony_ci} 864e41f4b71Sopenharmony_ci``` 865e41f4b71Sopenharmony_ci 866e41f4b71Sopenharmony_ci 867