我希望在我的主视图中有两个滚轮选择时间,其中一个包含01-24的数字,另一个包含00-60的数字,跳跃为5(0,5,10..55) 对于这样的事情? 类似于http://code.google.com/p/mobiscroll/,只是android内置。 时间选取器很烦人..我需要按+ - 直到我选择我想要的。我更喜欢更直观的东西。 我有什么选择存在这样的事情?时间选择器与滚动android?
0
A
回答
0
没有什么建立,但你可以试试这个: http://code.google.com/p/android-wheel/
+0
我试图导入文件夹为android项目,错误是:[2013-02-22 15:27:42 - Main]无法解析目标'android-3' [2013-02-22 15:44: 29 - 轮]无法解决目标'android-7' ' – buddy123 2013-02-22 13:45:18
0
你会发现这里的源代码一个完整的项目。 TestWheel.zip
- 下载
TestWheel.zip
从链接。 - 导入它在Eclipse
- 转换这个项目到库项目(在日testWheel项目右击==>属性==>安卓==>仄
is library
复选框)。 - 将此库项目添加到您的项目中。
- 将以下代码复制并粘贴到您的XML文件中。
0
这是你的hour_listView。只需为它设置一个字符串适配器。假设你可以使用ArrayAdapter填充一个listView。
hr_list.setOnScrollListener(new OnScrollListener() {
int currentcount,topitem,firstitem,lastitem;
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
if (scrollState == SCROLL_STATE_IDLE && currentcount == 4) {
while (scrollState == SCROLL_STATE_TOUCH_SCROLL) {
}
LinearLayout item = (LinearLayout) view.getChildAt(0);
int height = item.getHeight();
int top = Math.abs(item.getTop()); // top is a negative value
if (top <= height/2){
view.smoothScrollToPositionFromTop(topitem, 0, 3000);
Log.d("Switch", "up");
}
if(top> height/2){
view.smoothScrollToPositionFromTop(topitem+1, 0,3000);
Log.d("Switch", "down");
}
}
}
然后在button.clickListener上设置,您将得到可见listView的中心行号。
int list_hr = hr_list.getFirstVisiblePosition() - hr_list.getHeaderViewsCount();
很少关键。 *设置listView 1dp的分隔高度。 *使用线性布局在列表视图中排列 行高应该是列表视图高度(在dp中)的1/3。
XML的ListView和按钮
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Snap List"
android:textSize="25sp" />
<ListView
android:id="@+id/listView1"
android:layout_width="100dp"
android:layout_height="120dp"
android:fadingEdgeLength="33dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:layout_marginTop="73dp"
android:background="@drawable/lisbg"
android:scrollbars="none" >
</ListView>
<StackView
android:id="@+id/stackView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/listView1"
android:layout_marginLeft="103dp"
android:layout_marginTop="57dp"
android:layout_toRightOf="@+id/textView1" >
</StackView>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/textView1"
android:layout_marginRight="58dp"
android:text="OK" />
<Button
android:id="@+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button1"
android:layout_below="@+id/button1"
android:text="Scroll 5" />
XML为行。
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:textSize="25sp"
android:gravity="center_vertical|center_horizontal"
android:layout_gravity="center_vertical|center_horizontal"
android:text="TextView" />
相关问题
- 1. 选项卡时间选择器来选择时间范围,android
- 2. 摆动时间选择器
- 3. 时间选择器
- 4. AlarmManager不与时间选择器工作
- 5. 与Eonasdan日期时间选择器
- 6. 时间选择器当前和时间选择器时间之间的区别Android闹钟
- 7. 如何添加时间选择与日期选择器
- 8. 获取不同时区的时间选择时间选择器
- 9. Android CalendarView setOnDateChangeListener仅供选择 - 不滚动
- 10. 时间选择器错误
- 11. 当前时间选择器
- 12. 日期时间选择器
- 13. 日期时间选择器
- 14. ASP:时间选择器
- 15. 时间选择器(开源)
- 16. 日期/时间选择器++
- 17. 时间选择器问题
- 18. GWT时间选择器?
- 19. Chrome自动滚动到多个选择与选定的选项
- 20. 防止滚动目标选择器?
- 21. QTableView - 滚动时更改选择
- 22. iOS UITableView在滚动时不可选择
- 23. jquery ui选择菜单不会在Android浏览器中滚动
- 24. Android的 - 微调器选择消失当滚动ListView
- 25. Android N,L及以下分钟间隔时间选择器
- 26. android的时间选取器
- 27. 滚动2 TextView的在同一时间与Android工作室
- 28. 熊猫:滚动时间加权与GROUPBY
- 29. Android动画 - 选择动画时
- 30. 当滚动页面时颜色选择器不工作
我已经做了类似的事情。但名单不是循环的。你需要代码吗? – 2013-02-22 11:52:23
我不在乎它是否是循环的,我只需要一些可滚动的东西。没有什么是“专家”。同时我会尝试其他建议 – buddy123 2013-02-22 13:05:55
这适用于我的。它在列表视图上创建快照效果。如果你需要这个XML,请告诉我。 – 2013-02-22 13:31:03