开发者

Android view onUserVisible event

I'm writing some kind of messenger for android, and now I face the problem: I think about changing message state from unread to read when "Message is visible to user". Message is subclass of RelativeLayout, Messages organized into vertical layout with scrolling, which could be long, so I need visible event or something similar.

I found method void View.onDisplayHint(int hint) but docs say

Applications should not rely on this hint as there is no guarantee that they will receive one.

Any suggestions how to catch visibility to user change?

UPD: layout code if needed

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:weightSum="1"
    android:layout_height="fill_parent" android:orientation="vertical"
    android:id="@+id/conversation_main_layout">
    <RelativeLayout android:layout_height="wrap_content"
        android:id="@+id/relativeLayoutHeader" android:layout_width="fill_parent"
        android:background="@drawable/header_background_selector"
        android:padding="3px">
        <Button style="@style/header_button"
            android:layout_alignParentRight="true" android:text="@string/conversation_right_button"
            android:id="@+id/buttonCall"></Button>
        <Button style="@style/header_button" android:text="@string/conversation_left_button"
            android:layout_alignParentLeft="true" android:id="@+id/buttonInfo"></Button>
        <TextView android:layout_width="wrap_content" android:text="@string/conversation_header"
            android:layout_centerVertical="true" android:layout_centerHorizontal="true"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/textViewContactName" android:layout_height="wrap_content"></TextView>
    </RelativeLayout>
    <ScrollView android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:layout_margin="3dip"
        android:scrollbars="none">
        <LinearLayout android:id="@+id/linearLayoutDataHolder"
            android:orientation="vertical" android:l开发者_C百科ayout_width="match_parent"
            android:layout_height="match_parent">

        </LinearLayout>
    </ScrollView>
</LinearLayout>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜