Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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? 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.

Any tips?

like image 275
Marcos Vasconcelos Avatar asked Feb 04 '11 14:02

Marcos Vasconcelos


1 Answers

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();             
            }
        });
like image 60
Marcos Vasconcelos Avatar answered Oct 01 '22 23:10

Marcos Vasconcelos