跑马灯最后的重写
最后的override那个方法怎么写出来的
最后的override那个方法怎么写出来的
2015-10-15
MarqueeText,java:
package com.example.test_3;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;
public class MarqueeText extends TextView {
public MarqueeText(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public MarqueeText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
public MarqueeText(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
@Override
public boolean isFocused() {//实现滚动焦点强制
return true;
}
}
MainActivity.java:
package com.example.test_3;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);//使main_activity内容文本在APP上面运行(必须)
}
}
strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">test_3</string>
<string name="hello_world">明月装饰了我的梦,我装饰了别人的窗子!我是来自一个未知世界的奇妙小女子。。。</string>
<string name="action_settings">Settings</string>
</resources>
main_activity.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.example.test_3.MarqueeText
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="@string/hello_world" />
<com.example.test_3.MarqueeText
android:layout_below="@id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="@string/hello_world" />
</LinearLayout>
举报