Android 从超级视图组中获取单击的子视图

Android 从超级视图组中获取单击的子视图,android,xml,android-layout,chatsdk,Android,Xml,Android Layout,Chatsdk,我使用的是ChatSDK,在ChatSDK中有一个类似如下的activity_chat.xml <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/root" android:l

我使用的是ChatSDK,在ChatSDK中有一个类似如下的activity_chat.xml

 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/root"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:id="@+id/viewContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:animateLayoutChanges="true">

        <sdk.chat.ui.appbar.ChatActionBar
            android:id="@+id/chatActionBar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <sdk.chat.ui.views.ChatView
            android:id="@+id/chatView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@id/messageInputLinearLayout"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

        <LinearLayout
            android:id="@+id/messageInputLinearLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:orientation="vertical"
            app:layout_behavior="sdk.chat.ui.appbar.TextInputBehavior">

            <View
                android:id="@+id/divider"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginBottom="@dimen/_1sdp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:background="?chatViewDividerColor" />

            <sdk.chat.ui.views.ReplyView
                android:id="@+id/replyView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

            <com.stfalcon.chatkit.messages.MessageInput
                android:id="@+id/input"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="?chatViewMessageInputBackgroundColor"
                app:showAttachmentButton="true" />

        </LinearLayout>
    </androidx.coordinatorlayout.widget.CoordinatorLayout>

    <com.miguelcatalan.materialsearchview.MaterialSearchView
        android:id="@+id/searchView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

      </FrameLayout>
在这个方法中,我获得活动、视图和消息id,在onclick中,我想根据媒体播放器的状态显示播放或暂停图标。但是,每当我单击任何音频消息时,它总是更改最后一条音频消息的图标,它不会更改单击视图的图标,但是我总是收到正确的id和URL。所以当我尝试评估视图对象时,它是这样的

据我所知,我得到了根布局,现在我必须从messageList中找到单击的项,我已经尝试了足够多的研究,但找不到解决方案。请帮忙,谢谢

public static void onClick(Activity activity, View view, String url, long id) {
    BaseActivity.hideKeyboard(activity);
    if (!url.isEmpty()) {
        if (lastPlayingItemId != id || lastPlayingItemId == 0) {
            if (lastPlayingItemId != 0) audioPlayer.stop();
            imageViewState = null;
            lastPlayingItemId = id;
            imageViewState = view.findViewById(R.id.image_view_icon);
            audioPlayer = new AudioPlayer(url, playerEventListener);
        }
        if (!audioPlayer.isPlaying()) audioPlayer.play();
        else audioPlayer.stop();
    }
}