我最近遇到了一个问题,即ListView行中使用的不确定ProgressBar的动画变得不稳定.简而言之,我有一个ListView,每行包含一个ProgressBar.动画看起来很棒,直到我滚动;从那时起,至少有一个ProgressBar会有一个不稳定的动画.
有谁知道如何解决这个问题?
查看ListView行
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <ProgressBar android:indeterminate="true" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout>
简单的自定义ArrayAdapter
public class MyAdapter extends ArrayAdapter { List list; public MyAdapter(Context context,List objects) { super(context,objects); list = objects; } @Override public View getView(int position,View convertView,ViewGroup parent) { if(convertView == null) { convertView = ((LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.list_row,parent,false); } return convertView; } }
示例Activity的OnCreate()方法
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my); ListView listView = (ListView)findViewById(R.id.list_view); ArrayList<Integer> data = new ArrayList<Integer>(Arrays.asList(1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,17)); MyAdapter adapter = new MyAdapter(this,data); listView.setAdapter(adapter); }
记录错误(包含示例项目):https://code.google.com/p/android/issues/detail?id=145569&thanks=145569&ts=1423673226