I'm trying to handle SeekBar
's onProgressChange
event. I've added android:onProgressChanged="onSeekBarChanged"
to xml layout file and function in my Activity kotlin file:
fun onSeekBarChanged(view: View) {
Log.d(TAG, "on SeekBarChanged")
}
but compiler throwing following with error:
Android resource linking failed /home/radek/AndroidStudioProjects/TestMediaStore/app/build/intermediates/incremental/mergeDebugResources/stripped.dir/layout/activity_songfile_list.xml:37: error: attribute android:onProgressChanged not found. error: failed linking file resources.
What am I doing wrong?
Edit: This is also applicable to other event attributes from different listeners like:
android:onLongClick
android:onStartTrackingTouch
android:onCheckedChanged
android:onTextChanged
My layout:
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<data>
<variable name="viewModel" type="com.example.testmediastore.MyViewModel"/>
</data>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".SongFileListActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
</com.google.android.material.appbar.AppBarLayout>
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<include layout="@layout/songfile_list"/>
</FrameLayout>
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/seekbar_playback"
android:progress="@{viewModel.playerProgress}"
android:max="@{viewModel.playerProgressMax}"
android:onProgressChanged="onSeekBarChanged"
app:layout_behavior="@string/bottom_sheet_behavior"/>
<fragment
android:layout_width="wrap_content"
android:layout_height="@dimen/play_control_height"
android:name="com.example.testmediastore.PlayControlFragment"
android:id="@+id/fragment"
android:layout_gravity="bottom|center"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>