2

アプリケーションでandroid-wheel http://code.google.com/p/android-wheel/を使用しています。

画面に 3 つの車輪が並んでいます。ホイール内のテキストがホイールよりも広い場合、横にスクロールしたい(マーキーによる)

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

4

1 に答える 1

0

WheelView はそれ自体を無効にしなかったため、Activity に次のコードを追加します。

Handler handler = new Handler() {
    @Override
    public void handleMessage(Message msg) {
        super.handleMessage(msg);
        wheelview.invalidate();
        sendEmptyMessageDelayed(0, 0);
        }
};  
handler.sendEmptyMessage(0);

その後、TextView マーキー効果が機能しますが、Wh​​eelView をスクロールすると、TextView 文字列が最初からリセットされます。

ListView で TextView Marquee 効果を試してみましたが、Marquee 効果が機能します。ListView のソース コードを確認し、ListView と WheelView の違いを確認します。

于 2014-05-19T10:13:59.347 に答える