Code example for AbsListView

Methods: setEmptyView, setOnItemClickListener

1
        mListView = (AbsListView) view.findViewById(android.R.id.list);
        mEmptyView = (TextView) view.findViewById(android.R.id.empty);
        if (mListView == null) {
            throw new IllegalStateException("mast have a AbsListView with id(android.R.id.list)");
        } 
        mListView.setEmptyView(mEmptyView);
        mListView.setOnItemClickListener(this);
    } 
 
    @Override 
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mAdapter = createListAdapter(getActivity(), getData());
    } 
 
    protected abstract BaseAdapter createListAdapter(Context context, List<T> list);
 
    @Override 
    public void onLoadFinished(Loader<List<T>> arg0, List<T> arg1) {
        super.onLoadFinished(arg0, arg1);
        mAdapter.notifyDataSetChanged();