Próbuję użyć ViewFlipper, aby dodać animację między widokami, tak jak po wykonaniu samouczka na ten temat. Jednak wydaje się, że po prostu nie chce działać. Zmieni strony, ale nie otrzymam animacji - nawet jeśli dodaję ogromne opóźnienie do push_left_in.Brak animacji z ViewFlipper?
Oto mój onCreate:
@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 pochodzi z próbek Google. Oto działanie wyzwalacza:
@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)
A mój układ:
<?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>
Myśli?
Nic nie wyskakuje na mnie, choć nie użył MapView w ViewFlipper wcześniej. FWIW, oto przykładowy projekt pokazujący animacje z ViewFlipperem, na wypadek gdyby był pomocny: http://github.com/commonsguy/cw-android/tree/master/Fancy/Flipper2/ – CommonsWare
@CommonsOdtąd usunąłeś animacje z tego przykład. W czym problem? – ohhorob
@hobob: Przepraszam za to. Miało to jedynie uprościć przykład książki, ponieważ nie zajmowałem się animacjami nigdzie indziej w tej konkretnej książce. – CommonsWare