内容加载完成后删除加载微调器

时间:2014-04-13 21:17:52

标签: android facebook listview

我有这个imageview是一个自定义"微调器"旋转:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.call_activity);

    final ImageView z = (ImageView) findViewById(R.id.imageSpinner);
        Animation anim = AnimationUtils.loadAnimation(CallActivity.this, R.anim.spinner);
        z.startAnimation(anim);

我有这个列表视图:

@Override
        public void onComplete(List<Profile> friends) {

            // populate list
            List<String> values = new ArrayList<String>();
            for (Profile profile : friends) {
                //profile.getInstalled();
                values.add(profile.getName());          
            }

            ArrayAdapter<String> friendsListAdapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.list_items2, values);
            friendsListAdapter.sort(new Comparator<String>() {
                @Override
                public int compare(String lhs, String rhs) {
                    return lhs.compareTo(rhs);    
                }
            });

listview加载来自facebook的朋友。 我到目前为止的是列表加载,并且微调器仍然显示,我怎么能这样做,以便当listview加载其内容时,微调器消失?

------------- EDIT -----------------

        mSpinner = (ImageView) findViewById(R.id.imageSpinner);
        Animation anim = AnimationUtils.loadAnimation(CallActivity.this, R.anim.spinner);
        mSpinner.startAnimation(anim);

runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    mSpinner.setVisibility(View.GONE);
                }
                });

private ImageView mSpinner;

1 个答案:

答案 0 :(得分:1)

将您的微调器变为成员变量

private ImageView mSpinner;

protected void onCreate(Bundle savedInstanceState) {
    ...
    mSpinner = (ImageView) findViewById(R.id.imageSpinner);
    ...
}

并在onComplete方法

中添加以下内容
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            mSpinner.clearAnimation();
            mSpinner.setVisibility(View.GONE);
        }
    });