dependencies{
implementation 'io.openharmony.tpc.thirdlib:HorizontalPicker:1.0.1'
}
<com.goodiebag.horizontalpicker.HorizontalPicker
ohos:id="$+id:hpText"
ohos:height="match_content"
ohos:width="match_content"
ohos:layout_alignment="center"
app:textSize="18vp"
app:itemMargin="5vp"
app:itemHeight="40vp"
app:itemWidth="40vp"
app:backgroundNormal="$graphic:background_example"
app:backgroundSelected="$graphic:background_example_select"
app:textColor="#9b9b9b"
app:textColorSelected="#ffffff"/>
<com.goodiebag.horizontalpicker.HorizontalPicker
ohos:id="$+id:hpImage"
ohos:height="match_content"
ohos:width="match_content"
app:itemMargin="5vp"
app:itemHeight="40vp"
app:itemWidth="40vp"
app:backgroundNormal="$graphic:background_example"
app:backgroundSelected="$graphic:background_example_select"
app:textColor="#9b9b9b"
app:textColorSelected="#ffffff"/>
HorizontalPicker hpText = (HorizontalPicker)findComponentById(ResourceTable.Id_hpText);
HorizontalPicker hpImage = (HorizontalPicker)findComponentById(ResourceTable.Id_hpImage);
HorizontalPicker.OnSelectionChangeListener listener = new HorizontalPicker.OnSelectionChangeListener() {
@Override
public void onItemSelect(HorizontalPicker picker, int index) {
//picker选择的index
}
};
List<HorizontalPicker.PickerItem> textItems = new ArrayList<>();
for(int i=1;i<=4;i++){
textItems.add(new HorizontalPicker.TextItem("S"+i));
}
hpText.setItems(textItems,3);
List<HorizontalPicker.PickerItem> imageItems = new ArrayList<>();
imageItems.add(new HorizontalPicker.DrawableItem(ResourceTable.Media_icon_led));
imageItems.add(new HorizontalPicker.DrawableItem(ResourceTable.Media_icon_ir));
hpImage.setItems(imageItems);
hpImage.setSelectedIndex(0);
hpText.setChangeListener(listener);
hpImage.setChangeListener(listener);
public void setItems(List items)
public void setItems(List items, int selectedIndex)
public List getItems()
public void setSelectedIndex(int selectedIndex)
public PickerItem getSelectedItem()
public Element getBackground()
public Element getBackgroundSelected()
public void setBackground(int normal, int selected)
public int getColorNormal()
public int getColorSelected()
public void setColorSelector(int normal, int selected)
public int getTextSize()
public void setTextSize(int textSize)
public int getItemWidth()
public void setItemWidth(int itemWidth)
public int getItemMargin()
public void setItemMargin(int itemMargin)
public int getItemHeight()
public void setItemHeight(int itemHeight)
public OnSelectionChangeListener getChangeListener()
public void setChangeListener(OnSelectionChangeListener changeListener)
name | format | description |
---|---|---|
backgroundNormal | element | get defualt background element |
backgroundSelected | element | get selected background element |
textColor | color | set default text color |
textColorSelected | color | set selected text color |
textSize | dimension | set text size |
itemHeight | dimension | set item height |
itemWidth | dimension | set item width |
itemMargin | dimension | set item margin |
MIT License
Copyright (c) 2017 GoodieBag
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型