use of in.srain.cube.views.list.ListViewDataAdapter in project android-Ultra-Pull-To-Refresh by liaohuqiu.
the class WithLongPressFragment method createView.
@Override
protected View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mImageLoader = ImageLoaderFactory.create(getActivity());
View view = inflater.inflate(R.layout.fragment_with_long_press, null);
setHeaderTitle(R.string.ptr_demo_block_with_long_press);
final PtrFrameLayout ptrFrameLayout = (PtrFrameLayout) view.findViewById(R.id.with_long_press_list_view_frame);
ListView listView = (ListView) view.findViewById(R.id.with_long_press_list_view);
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(getContext(), "Long Pressed: " + id, Toast.LENGTH_SHORT).show();
return true;
}
});
final ListViewDataAdapter<String> listViewDataAdapter = new ListViewDataAdapter<String>();
listViewDataAdapter.setViewHolderClass(this, ViewHolder.class);
ptrFrameLayout.setPtrHandler(new PtrDefaultHandler() {
@Override
public void onRefreshBegin(PtrFrameLayout frame) {
ptrFrameLayout.postDelayed(new Runnable() {
@Override
public void run() {
listViewDataAdapter.getDataList().clear();
listViewDataAdapter.getDataList().addAll(Arrays.asList(Images.imageUrls));
listViewDataAdapter.notifyDataSetChanged();
ptrFrameLayout.refreshComplete();
}
}, 2000);
}
});
ptrFrameLayout.postDelayed(new Runnable() {
@Override
public void run() {
ptrFrameLayout.autoRefresh();
}
}, 100);
listView.setAdapter(listViewDataAdapter);
return view;
}
Aggregations