Listview加載動畫
阿新 • • 發佈:2017-09-06
eight @override handler prot code wid lists line for
private ArrayList<String> list; private Handler handler=new Handler(); private ArrayAdapter<String> adapter; private GridView grid; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView tv= (TextView) findViewById(R.id.tv); grid= (GridView) findViewById(R.id.brid); Animation animation=new ScaleAnimation(1.0f,2.0f,1.0f,2.0f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f); animation.setDuration(5000); animation.setFillAfter(true); tv.startAnimation(animation); list=new ArrayList<String>(); for (int i=0;i<10;i++){ list.add("我是第"+i+"行"); } adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,list); handler.postDelayed(new Runnable() { @Override public void run() { grid.setAdapter(adapter); } },5000);
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.bwie.wangshaoliang20170906.MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/tv" android:text="哈哈哈哈哈" android:layout_gravity="center" /> <GridView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/brid" android:layout_marginTop="1dp" android:listSelector="@color/colorAccent" android:drawSelectorOnTop="false" android:fadingEdgeLength="0.0dp" android:layoutAnimation="@anim/grid_layout" android:cacheColorHint="@android:color/transparent" > </GridView> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:fromXDelta="-100%" android:fromYDelta="0" android:toXDelta="0" android:toYDelta="0" android:duration="2550" android:interpolator="@android:anim/anticipate_overshoot_interpolator"></translate> </set>
<?xml version="1.0" encoding="utf-8"?> <layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android" android:animation="@anim/liat_anim" android:animationOrder="normal" android:delay="0.5" />
Listview加載動畫