6 Star 1 Fork 0

HarmonyOS-TPC / HorizontalPicker

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Demo

USED:

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);

API:

class:HorizontalPicker

public void setItems(List items)

  • description: set items

public void setItems(List items, int selectedIndex)

  • description: set items and frist selected index

public List getItems()

  • description: get items

public void setSelectedIndex(int selectedIndex)

  • description: set selected item with index

public PickerItem getSelectedItem()

  • description: get selected item

public Element getBackground()

  • description: get default background element

public Element getBackgroundSelected()

  • description: get selected background element

public void setBackground(int normal, int selected)

  • description: set defualt background and selected background with xml ID

public int getColorNormal()

  • description: get defualt color

public int getColorSelected()

  • description: get selected color

public void setColorSelector(int normal, int selected)

  • description: set default color and selected color

public int getTextSize()

  • description: get text size

public void setTextSize(int textSize)

  • description: set text size

public int getItemWidth()

  • description: get item width

public void setItemWidth(int itemWidth)

  • description: set item width

public int getItemMargin()

  • description: get item margin

public void setItemMargin(int itemMargin)

  • description: set item margin

public int getItemHeight()

  • description: get item height

public void setItemHeight(int itemHeight)

  • description: set item height

public OnSelectionChangeListener getChangeListener()

  • description: get selected change listener

public void setChangeListener(OnSelectionChangeListener changeListener)

  • description: set selected change listener

AttrSet:

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

LICENSE :

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.
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.

简介

暂无描述 展开 收起
Java
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/HarmonyOS-tpc/HorizontalPicker.git
git@gitee.com:HarmonyOS-tpc/HorizontalPicker.git
HarmonyOS-tpc
HorizontalPicker
HorizontalPicker
master

搜索帮助