如何使ListView在显示时不刷新其项目

时间:2014-07-08 13:49:56

标签: android listview

我想在我的ListView中显示我的视频的预览,我已经通过简单地使用SeekTo()方法完成了它,但每当我的ListView通过通知适配器刷新时,此过程也明显刷新,

        holder.PvideoView.setVideoURI(Uri.parse((mCursor.getString
        (mCursor.getColumnIndex("isfile")).split("\\@ADAT")[1]))); 

        holder.PvideoView.seekTo(3000);

我需要知道的是,如果流程已经完成,有一种方法不能自我刷新,

1 个答案:

答案 0 :(得分:0)

Afaik它将永远刷新自己。您可以做的是将预览的当前状态信息存储在数据类中,该数据类用于列表视图并在重新初始化后将其设置为视频。

@Override
  public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) context
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View rootView= inflater.inflate(R.layout.yourLayout, parent, false);
    VideoView videoView = (VideoView) rootView.findViewById(R.id.yourVideoId);
    NotifyVideoUpdate(videoView, values[position]);
    videoView.seekTo(values[position].CurrentTime);
    return rootView;
  }

  public void NotifyVideoUpdate(VideoView view, VideoModel model){
      //no idea how to add a listener to the video preview, but add it here and change
     // the value inside of your model
  }