简体   繁体   English

画廊活动“以图像为中心”

[英]Gallery event to “when image centered”

I'm creating an scrollable image picker, but there's some info that I want to show for each Image while scrooling, my question is, there's an event on the Gallery that notify me that a Image is centered? 我正在创建一个可滚动的图像选择器,但有一些信息我希望在每个图像中显示时,我的问题是,在Gallery上有一个事件通知我图像居中? This event should happen when scrolling. 滚动时应该发生此事件。

My Layout is that: 我的布局是这样的:

    <Gallery android:id="@+id/coverflow"
        android:layout_width="match_parent" android:layout_height="wrap_content"
        android:layout_centerInParent="true" />
    <TextView android:id="@+id/author" android:layout_width="match_parent"
        android:layout_height="wrap_content" android:text="Titulo livro"
        android:layout_above="@id/coverflow" android:gravity="center" />

    <ImageView android:id="@+id/div" android:layout_width="match_parent"
        android:layout_height="wrap_content" android:src="@drawable/library_div"
        android:layout_above="@id/author" />

    <TextView android:id="@+id/title" android:layout_width="match_parent"
        android:layout_height="wrap_content" android:text="Author"
        android:layout_above="@id/div" android:gravity="center" />
</RelativeLayout>

I want to when scroll happens and a new iten is the middle one, the author and title TextViews get updated. 我想在滚动发生时,新的iten是中间的,作者和标题TextViews得到更新。

Any tips? 有小费吗?

Actually I found it: 其实我找到了:

coverflow.setCallbackDuringFling(true);
        coverflow.setOnItemSelectedListener(new OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> arg0, View arg1,
                    int arg2, long arg3) {
                Toast.makeText(LibraryActivity.this, "SELECTING "+arg2, Toast.LENGTH_SHORT).show();             
            }

            @Override
            public void onNothingSelected(AdapterView<?> arg0) {
                Toast.makeText(LibraryActivity.this, "NOTHING", Toast.LENGTH_SHORT).show();             
            }
        });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM