我的布局看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.plarke.proto1.QuizActivity">
<Button
android:id="@+id/compare_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="16dp"
android:layout_marginRight="16dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginEnd="16dp" />
<TextView
android:id="@+id/compare_score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="16dp"
android:layout_marginLeft="16dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginStart="16dp" />
<SeekBar
android:id="@+id/compare_pitchbar"
android:layout_width="0dp"
android:layout_height="23dp"
android:layout_marginBottom="50dp"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:progressBackgroundTint="@color/colorAccent"
android:progressBackgroundTintMode="src_over"
app:layout_constraintBottom_toTopOf="@+id/textView"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<Button
android:id="@+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
app:layout_constraintBottom_toTopOf="@+id/button2"
tools:text="The seekbar is all the way to the left."
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent" …Run Code Online (Sandbox Code Playgroud) object.__dict__ 和其他地方的隐藏方法设置为这样的事情:
<dictproxy {'__add__': <slot wrapper '__add__' of 'instance' objects>,
'__and__': <slot wrapper '__and__' of 'instance' objects>,
'__call__': <slot wrapper '__call__' of 'instance' objects>,
'__cmp__': <slot wrapper '__cmp__' of 'instance' objects>,
'__coerce__': <slot wrapper '__coerce__' of 'instance' objects>,
'__contains__': <slot wrapper '__contains__' of 'instance' objects>,
'__delattr__': <slot wrapper '__delattr__' of 'instance' objects>,
'__delitem__': <slot wrapper '__delitem__' of 'instance' objects>,
'__delslice__': <slot wrapper '__delslice__' of 'instance' objects>,
'__div__': <slot wrapper '__div__' of 'instance' objects>,
'__divmod__': <slot wrapper '__divmod__' of 'instance' objects>, …Run Code Online (Sandbox Code Playgroud) 我有一个自定义视图QuizBar,该视图是SeekBar(实际上是android.support.v7.widget.AppCompatSeekBar谁在乎的)子类,我想为其创建事件监听器。查看SeekBar源代码,我看到它更新了事件监听器,如下所示:
@Override
void onProgressRefresh(float scale, boolean fromUser, int progress) {
super.onProgressRefresh(scale, fromUser, progress);
if (mOnSeekBarChangeListener != null) {
mOnSeekBarChangeListener.onProgressChanged(this, progress, fromUser);
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试做同样的事情时,在超级调用上出现错误cannot resolve method onProgressRefresh(float, boolean, int)。为什么是这样?如果不允许这样做,如何创建自定义事件监听器?
我的代码:
@Override
void onProgressRefresh(float scale, boolean fromUser, int progress) {
super.onProgressRefresh(scale, fromUser, progress);
if (mOnQuizBarChangeListener != null) {
mOnQuizBarChangeListener.onProgressChanged(this, progress, fromUser);
}
}
Run Code Online (Sandbox Code Playgroud)