1/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.widget.listview;
18
19import com.android.frameworks.coretests.R;
20
21import android.app.ListActivity;
22import android.database.Cursor;
23import android.os.Bundle;
24import android.provider.Contacts.People;
25import android.view.animation.AlphaAnimation;
26import android.view.animation.Animation;
27import android.view.animation.AnimationSet;
28import android.view.animation.LayoutAnimationController;
29import android.view.animation.TranslateAnimation;
30import android.widget.ListAdapter;
31import android.widget.ListView;
32import android.widget.SimpleCursorAdapter;
33import android.widget.Toast;
34
35/**
36 * See 1080989. You need some contacts for this adapter.
37 */
38public class ListWithDisappearingItemBug extends ListActivity {
39
40    @Override
41    protected void onCreate(Bundle savedInstanceState) {
42        super.onCreate(savedInstanceState);
43
44        Toast.makeText(this, "Make sure you rotate screen to see bug", Toast.LENGTH_LONG).show();
45
46        // Get a cursor with all people
47        Cursor c = getContentResolver().query(People.CONTENT_URI, null, null, null, null);
48        startManagingCursor(c);
49
50        ListAdapter adapter = new SimpleCursorAdapter(this,
51                // Use a template that displays a text view
52                R.layout.list_with_disappearing_item_bug_item,
53                // Give the cursor to the list adatper
54                c,
55                // Map the NAME column in the people database to...
56                new String[] {People.NAME} ,
57                // The "text1" view defined in the XML template
58                new int[] {R.id.text1});
59        setListAdapter(adapter);
60
61        AnimationSet set = new AnimationSet(true);
62
63        Animation animation = new AlphaAnimation(0.0f, 1.0f);
64        animation.setDuration(50);
65        set.addAnimation(animation);
66
67        animation = new TranslateAnimation(
68            Animation.RELATIVE_TO_SELF, 0.0f,Animation.RELATIVE_TO_SELF, 0.0f,
69            Animation.RELATIVE_TO_SELF, -1.0f,Animation.RELATIVE_TO_SELF, 0.0f
70        );
71        animation.setDuration(100);
72        set.addAnimation(animation);
73
74        LayoutAnimationController controller =
75                new LayoutAnimationController(set, 0.5f);
76        ListView listView = getListView();
77        listView.setLayoutAnimation(controller);
78    }
79
80}
81