0

次のコードを見てください

<TableRow
          android:id="@+id/tableRow13"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:padding="5dp" >

            <TextView
                 android:id="@+id/textView22"
                  android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:textColor="#ffffff"
                 android:textSize="12sp"
                 android:text="@string/r_new_event"
                 android:layout_marginLeft="5dp"
                 android:textAppearance="?android:attr/textAppearanceSmall" />

             <TextView
                 android:id="@+id/textView23"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="Meeting with people i have never seen before in my entire life lol"
                 android:ellipsize="marquee"
                 android:maxLength="10"
                 android:singleLine="true"
                 android:fadingEdge="horizontal"
                 android:marqueeRepeatLimit="marquee_forever"
                 android:scrollHorizontally="true"
                 android:textColor="#ffffff"
                 android:textSize="12sp"
                 android:layout_marginLeft="10dp"
                 android:textAppearance="?android:attr/textAppearanceSmall" />

</TableRow>

この試みは、テキストが 10 文字を超える場合にマーキー化することです。残念ながら、このコードは機能しません。mothエミュレーターとAndroidフォンで試してみました。ここで何が問題なのですか?

アップデート

以下は私の新しいコードですが、まだ機能していません

<TextView
    android:id="@+id/textView23"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Meeting with people i have never seen before in my entire life lol"
    android:ellipsize="marquee"
    android:maxLength="10"
    android:singleLine="true"
    android:fadingEdge="horizontal"
    android:marqueeRepeatLimit="marquee_forever"
    android:scrollHorizontally="true"
    android:textColor="#ffffff"
    android:textSize="12sp"
    android:layout_marginLeft="10dp"
    android:focusable="true" 
android:focusableInTouchMode="true" 
    android:freezesText="true"
    android:textAppearance="?android:attr/textAppearanceSmall" />
4

4 に答える 4

0

以下のカスタム TextView / onCreate を使用して、 your_textView.setSelected(true); と書くだけです。

public class MyTextView extends TextView {

public MyTextView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
}

public MyTextView(Context context, AttributeSet attrs) {
    super(context, attrs);
}

public MyTextView(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;
}

}

于 2013-10-29T13:11:38.350 に答える