Mar*_*los 7 events android scroll gallery coverflow
我正在创建一个可滚动的图像选择器,但有一些信息我希望在每个图像中显示时,我的问题是,在Gallery上有一个事件通知我图像居中?滚动时应该发生此事件.
我的布局是这样的:
<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>
Run Code Online (Sandbox Code Playgroud)
我想在滚动发生时,新的iten是中间的,作者和标题TextViews得到更新.
有小费吗?
Mar*_*los 10
其实我找到了:
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();
}
});
Run Code Online (Sandbox Code Playgroud)