Tôi đang cố gắng sử dụng ViewFlipper để thêm hoạt ảnh giữa các chế độ xem, như trong hướng dẫn sau về chủ đề. Tuy nhiên, nó dường như không muốn làm việc. Nó sẽ thay đổi các trang, nhưng tôi sẽ không có hoạt ảnh - ngay cả khi tôi thêm một sự chậm trễ lớn vào push_left_in.Không có hoạt ảnh với ViewFlipper?
Dưới đây là onCreate của tôi:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
viewFlipper = (ViewFlipper)findViewById(R.id.flipper);
viewFlipper.setAnimation(AnimationUtils.loadAnimation(this, R.anim.push_left_in));
mapView = (MapView)findViewById(R.id.mapView);
mapView.setBuiltInZoomControls(true);
}
push_left_in xuất phát từ mẫu của Google. Đây là hành động kích hoạt:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.button_map:
viewFlipper.setDisplayedChild(0);
return true;
case R.id.button_conditions_general:
viewFlipper.setDisplayedChild(1);
return true;
(etc)
Và bố trí của tôi:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/mainlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ViewFlipper android:id="@+id/flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<view class="com.google.android.maps.MapView"
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="MY_API_KEY"
/>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:stretchColumns="1"
>
<TableRow>
<TextView android:id="@+id/field1"
android:layout_column="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="18px"
android:text="@string/field1"
>
</TextView>
<EditText android:text="100"
android:id="@+id/field2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</EditText>
<TextView android:id="@+id/field3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="18px"
android:text="%"
>
</TextView>
</TableRow>
</TableLayout>
</ViewFlipper>
</LinearLayout>
Suy nghĩ?
Không có gì nhảy ra khỏi tôi, mặc dù tôi đã không sử dụng một MapView trong một ViewFlipper trước. FWIW, đây là một dự án mẫu hiển thị hoạt ảnh với ViewFlipper, trong trường hợp nó giúp: http://github.com/commonsguy/cw-android/tree/master/Fancy/Flipper2/ – CommonsWare
@CommonsBạn đã xóa hoạt ảnh khỏi đó thí dụ. Có vấn đề gì thế? – ohhorob
@ohhorob: Xin lỗi về điều đó. Chỉ đơn giản là làm ví dụ về cuốn sách, vì tôi không giải quyết các hoạt ảnh ở bất kỳ nơi nào khác trong cuốn sách cụ thể đó. – CommonsWare