请选择 进入手机版 | 继续访问电脑版

技术控

    今日:9| 主题:61554
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] SGiOSViews

[复制链接]
情不自禁的想你 发表于 2016-10-5 16:16:08
176 1
Common iOS Views ported to Android

  Requirements

  Android Studio (gradle) Min sdk 15
  Demo

  Usage

  Add this to your build.gradle dependencies
  1. compile 'com.github.shubhank101.sgiosviews:sgiosviews-lib:1.0.0'
复制代码
SGStepper

  A port of iOS UIStepper, can be used a simple number picker
  Usage

  Add the following code to the root element of layout
  1. xmlns:stepper="http://schemas.android.com/apk/res-auto"
复制代码
Adding the element to the xml
  1. <com.sgiosviews.SGStepper   
  2.     android:id="@+id/stepper"
  3.     android:layout_width="wrap_content"
  4.     android:layout_height="20dp"
  5.     stepper:roundedradius="0dp"
  6.     stepper:bordercolor="#fff"
  7.     stepper:highlightcolor="#ccc"
  8. />
复制代码
Getting Values in Java
  1. SGStepper stepper = (SGStepper)findViewById(R.id.stepper);
  2. stepper.setValueChangedlistener(new SGStepper.SGStepperListener() {
  3.     @Override
  4.     public void valuesChanged(SGStepper stepper, int newValue) {
  5.     }
  6.     @Override
  7.     public void afterValueChanged(SGStepper stepper, int finalValue) {
  8.     }
  9. });
复制代码
SGPickerView

  A very basic port of iOS UIPickerView.
  Usage

  Add the following code to the root element of layout
  1. xmlns:picker="http://schemas.android.com/apk/res-auto"
复制代码
Adding the element to the xml
  1. <com.sgiosviews.SGPickerView
  2.     android:id="@+id/pickerView"
  3.     android:layout_width="match_parent"
  4.     android:layout_marginRight="20dp"
  5.     android:layout_marginLeft="20dp"
  6.     android:layout_marginBottom="40dp"
  7.     android:layout_height="wrap_content"
  8.     picker:defaultTextColor="#ccc"
  9.     picker:selectedTextColor="#666"/>
复制代码
Setting Picker Values in Java
  1. pickerView = (SGPickerView)findViewById(R.id.pickerView);
  2. ArrayList<String> items = new ArrayList<String>();
  3. items.add("Funny");
  4. items.add("Awesomeeeee");
  5. pickerView.setItems(items);
复制代码
Listening to any new selection of element
  1. pickerView.setPickerListener(new SGPickerView.SGPickerViewListener() {
  2.     @Override
  3.     public void itemSelected(String item, int index) {
  4.         Toast.makeText(MainActivity.this, " Index = " + String.valueOf(index) + " Item name " + item, Toast.LENGTH_SHORT).show();
  5.     }
  6. });
复制代码
Public methods to access selected index or item at any time
  1. pickerView.getCurrentSelectedItemIndex();
  2. pickerView.getCurrentSelectedItem();
复制代码
Developed By

  Shubhank Gupta,    [email protected]  
  License

  Copyright (c) 2016 Shubhank Gupta, Licensed under the MIT license.
醉易、 发表于 2016-10-5 18:05:10
有的人聪明得像天气,多变;有的人傻得像天气预报,变天它都看不出来。
回复 支持 反对

使用道具 举报

我要投稿

推荐阅读


回页顶回复上一篇下一篇回列表
手机版/c.CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 | 粤公网安备 44010402000842号 )

© 2001-2017 Comsenz Inc.

返回顶部 返回列表