如何将文本发送到 Android 轮盘中的选框?
我正在使用 android-wheel http://code.google.com/p/android-wheel / 在应用程序中。
我的屏幕上并排有三个轮子。当轮子中的文本比轮子宽时,我希望它滚动到侧面(按照选框)
我已经实现了一个 AbstractWheelTextAdapter
并创建了一个自定义 ScrollingTextView
项目如下:(ScrollingTextView
是为了克服选框仅在项目具有焦点时才工作的问题)
public class ScrollingTextView extends TextView {
public ScrollingTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public ScrollingTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ScrollingTextView(Context context) {
super(context);
}
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
if(focused)
super.onFocusChanged(focused, direction, previouslyFocusedRect);
}
@Override
public void onWindowFocusChanged(boolean focused) {
if(focused)
super.onWindowFocusChanged(focused);
}
@Override
public boolean isFocused() {
return true;
}
}
和 xml:
<com.test.app.ScrollingTextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id = "@+id/wheel_text"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:inputType="text"
android:scrollHorizontally="true"
android:textColor="#F000"
android:lines="1"
android:focusable="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"/>
有人能够让它工作吗?
(我还尝试在 AbstractWheelTextAdapter
的代码中设置 Ellipse ,但没有成功)
I am using the android-wheel http://code.google.com/p/android-wheel/ in an application.
I have three of the wheels side by side on my screen. When the text in a wheel is wider than the wheel I would like it to scroll to the side (As per Marquee)
I have implemented an AbstractWheelTextAdapter
and created a custom ScrollingTextView
for the items as follows: (ScrollingTextView
is to overcome the issue with Marquee only working when an item has focus)
public class ScrollingTextView extends TextView {
public ScrollingTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public ScrollingTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ScrollingTextView(Context context) {
super(context);
}
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
if(focused)
super.onFocusChanged(focused, direction, previouslyFocusedRect);
}
@Override
public void onWindowFocusChanged(boolean focused) {
if(focused)
super.onWindowFocusChanged(focused);
}
@Override
public boolean isFocused() {
return true;
}
}
And the xml:
<com.test.app.ScrollingTextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id = "@+id/wheel_text"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:inputType="text"
android:scrollHorizontally="true"
android:textColor="#F000"
android:lines="1"
android:focusable="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"/>
Has anyone been able to get this to work?
(I have also tried setting the Ellipse in the code for the AbstractWheelTextAdapter
without success)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为WheelView本身并没有失效。在Activity中,添加代码:
然后TextView跑马灯效果就起作用了。但是当你滚动WheelView时,TextView字符串从头开始重置。
我在ListView中尝试过TextView跑马灯效果,跑马灯效果有效。我要检查ListView源代码,看看ListView和WheelView之间有什么区别。
Because the WheelView didn't invalidate itself.In Activity,add the code :
Then the TextView Marquee effect works.But when you scroll the WheelView,the TextView string reset from start.
I had try the TextView Marquee effect in ListView, the Marquee effect works.I gonna check the ListView source code ,see what differences between ListView and WheelView.