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_conten开发者_开发百科t"
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?
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();
}
});
精彩评论