TextView 会报错
Android studio中 TextView 会报错 This custom view should extend android.support.v7.widget.AppCompatTextView instead 应该怎么解决
Android studio中 TextView 会报错 This custom view should extend android.support.v7.widget.AppCompatTextView instead 应该怎么解决
 
                            2018-05-08
这个自定义视图应该继承android.support.v7.widget.AppCompatTextView,我是这样写的成功,不过在eclipse下的。
package com.example.studyandroid;import android.content.Context;import android.util.AttributeSet;import android.widget.TextView;public class Marquee extends TextView {	public Marquee(Context context) {		super(context);		// TODO Auto-generated constructor stub	}	public Marquee(Context context, AttributeSet attrs, int defStyle) {		super(context, attrs, defStyle);		// TODO Auto-generated constructor stub	}	public Marquee(Context context, AttributeSet attrs) {		super(context, attrs);		// TODO Auto-generated constructor stub	}	@Override	public boolean isFocused() {		return true;	}}<com.example.studyandroid.Marquee android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/button2" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:singleLine="true" android:text="@string/hello_world" /> <com.example.studyandroid.Marquee android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/textView1" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:singleLine="true" android:text="@string/hello_world" />
你要不在extends 后改成 AppCompatTextView ,导入android.support.v7.widget.AppCompatTextView
举报