如何使用动画关闭 Listview就像 ListView 的最后一个项目是第一个,第二个最后一个是第二个等等。就像它来了一样。我已经使用以下链接完成了此操作:http: //developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/LayoutAnimation2.html 我想要相反的顺序。
我有一个自定义ListView
,我编写了以下代码。
public class Hella_AdlightActivity extends Activity implements OnItemClickListener {
private ListView mListView = null;
private ItemList_BaseAdapter mBaseAdapter = null;
private Drawable photoId[] = new Drawable[4];
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
photoId[0] = getResources().getDrawable(R.drawable.one_);
photoId[1] = getResources().getDrawable(R.drawable.two_);
photoId[2] = getResources().getDrawable(R.drawable.three_);
photoId[3] = getResources().getDrawable(R.drawable.four_);
mListView = (ListView)findViewById(R.id.lst_item);
mListView.setCacheColorHint(0);
getAnimation();
mBaseAdapter = new ItemList_BaseAdapter(this);
mListView.setAdapter(mBaseAdapter);
mListView.setOnItemClickListener(this);
}
private void getAnimation(){
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(3000);
set.addAnimation(animation);
animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0.0f,Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, -1.0f,Animation.RELATIVE_TO_SELF, 0.0f
);
animation.setDuration(2000);
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(set, 1.0f);
mListView.setLayoutAnimation(controller);
}
private class ItemList_BaseAdapter extends BaseAdapter{
private LayoutInflater mLayout = null;
private Context mContext = null;
public ItemList_BaseAdapter(Context context){
this.mContext = context;
this.mLayout = LayoutInflater.from(mContext);
}
public int getCount() {
return photoId.length;
}
public Object getItem(int arg0) {
return null;
}
public long getItemId(int position) {
return 0;
}
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null) {
convertView = mLayout.inflate(R.layout.cust_list, null);
}
ImageView imgItem = (ImageView)convertView.findViewById(R.id.img_items);
imgItem.setBackgroundDrawable(photoId[position]);
return convertView;
}
}
}
我为 Listview Load 执行此操作,并且我想在用户链接任何列表项时关闭列表