Search in sources :

Example 76 with ListAdapter

use of android.widget.ListAdapter in project android-vertical-slide-view by xmuSistone.

the class VerticalFragment2 method initView.

/**
	 * 初始化ListView
	 * 
	 * @param rootView
	 *            根View
	 */
private void initView(View rootView) {
    ListView listview = (ListView) rootView.findViewById(R.id.fragment2_listview);
    ListAdapter adapter = new BaseAdapter() {

        private LayoutInflater inflater;

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (inflater == null) {
                inflater = LayoutInflater.from(getActivity());
            }
            if (null == convertView) {
                convertView = inflater.inflate(R.layout.fragment2_list_item, null);
            }
            return convertView;
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public Object getItem(int position) {
            return position;
        }

        @Override
        public int getCount() {
            return 100;
        }
    };
    listview.setAdapter(adapter);
}
Also used : ListView(android.widget.ListView) ViewGroup(android.view.ViewGroup) LayoutInflater(android.view.LayoutInflater) BaseAdapter(android.widget.BaseAdapter) View(android.view.View) ListView(android.widget.ListView) ListAdapter(android.widget.ListAdapter)

Example 77 with ListAdapter

use of android.widget.ListAdapter in project android_frameworks_base by ResurrectionRemix.

the class TransparentListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setBackgroundDrawable(getResources().getDrawable(R.drawable.gradient));
    setContentView(R.layout.list_activity);
    ListAdapter adapter = new SimpleListAdapter(this);
    ListView list = (ListView) findViewById(R.id.list);
    list.setAdapter(adapter);
    list.setCacheColorHint(0);
    list.setVerticalFadingEdgeEnabled(true);
    registerForContextMenu(list);
}
Also used : ListView(android.widget.ListView) ListAdapter(android.widget.ListAdapter)

Example 78 with ListAdapter

use of android.widget.ListAdapter in project ride-read-android by Ride-Read.

the class ListViewMeasure method setListViewHeightBaseAdapter.

public static void setListViewHeightBaseAdapter(ListView listViewHeightBaseAdapter) {
    ListAdapter adapter = listViewHeightBaseAdapter.getAdapter();
    if (adapter == null) {
        return;
    }
    int totalHeight = 0;
    for (int i = 0; i < adapter.getCount(); i++) {
        View listItem = adapter.getView(i, null, listViewHeightBaseAdapter);
        listItem.measure(0, 0);
        totalHeight += listItem.getMeasuredHeight();
    }
    ViewGroup.LayoutParams params = listViewHeightBaseAdapter.getLayoutParams();
    params.height = totalHeight + (listViewHeightBaseAdapter.getDividerHeight() * (adapter.getCount() - 1));
    listViewHeightBaseAdapter.setLayoutParams(params);
}
Also used : ViewGroup(android.view.ViewGroup) View(android.view.View) ListView(android.widget.ListView) ListAdapter(android.widget.ListAdapter)

Example 79 with ListAdapter

use of android.widget.ListAdapter in project LshUtils by SenhLinsh.

the class ViewUtils method getListViewHeightBasedOnChildren.

/**
     * 根据所有条目计算ListView的高
     */
public static int getListViewHeightBasedOnChildren(ListView view) {
    int height = getAbsListViewHeightBasedOnChildren(view);
    ListAdapter adapter;
    int adapterCount;
    if (view != null && (adapter = view.getAdapter()) != null && (adapterCount = adapter.getCount()) > 0) {
        height += view.getDividerHeight() * (adapterCount - 1);
    }
    return height;
}
Also used : Point(android.graphics.Point) ListAdapter(android.widget.ListAdapter)

Example 80 with ListAdapter

use of android.widget.ListAdapter in project android_frameworks_base by ResurrectionRemix.

the class ListFragment method ensureList.

private void ensureList() {
    if (mList != null) {
        return;
    }
    View root = getView();
    if (root == null) {
        throw new IllegalStateException("Content view not yet created");
    }
    if (root instanceof ListView) {
        mList = (ListView) root;
    } else {
        mStandardEmptyView = (TextView) root.findViewById(com.android.internal.R.id.internalEmpty);
        if (mStandardEmptyView == null) {
            mEmptyView = root.findViewById(android.R.id.empty);
        } else {
            mStandardEmptyView.setVisibility(View.GONE);
        }
        mProgressContainer = root.findViewById(com.android.internal.R.id.progressContainer);
        mListContainer = root.findViewById(com.android.internal.R.id.listContainer);
        View rawListView = root.findViewById(android.R.id.list);
        if (!(rawListView instanceof ListView)) {
            throw new RuntimeException("Content has view with id attribute 'android.R.id.list' " + "that is not a ListView class");
        }
        mList = (ListView) rawListView;
        if (mList == null) {
            throw new RuntimeException("Your content must have a ListView whose id attribute is " + "'android.R.id.list'");
        }
        if (mEmptyView != null) {
            mList.setEmptyView(mEmptyView);
        } else if (mEmptyText != null) {
            mStandardEmptyView.setText(mEmptyText);
            mList.setEmptyView(mStandardEmptyView);
        }
    }
    mListShown = true;
    mList.setOnItemClickListener(mOnClickListener);
    if (mAdapter != null) {
        ListAdapter adapter = mAdapter;
        mAdapter = null;
        setListAdapter(adapter);
    } else {
        // have our data right away and start with the progress indicator.
        if (mProgressContainer != null) {
            setListShown(false, false);
        }
    }
    mHandler.post(mRequestFocus);
}
Also used : ListView(android.widget.ListView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListAdapter(android.widget.ListAdapter)

Aggregations

ListAdapter (android.widget.ListAdapter)298 ListView (android.widget.ListView)105 View (android.view.View)96 AdapterView (android.widget.AdapterView)55 AbsListView (android.widget.AbsListView)48 WrapperListAdapter (android.widget.WrapperListAdapter)47 HeaderViewListAdapter (android.widget.HeaderViewListAdapter)44 TextView (android.widget.TextView)42 ViewGroup (android.view.ViewGroup)37 Paint (android.graphics.Paint)22 ArrayAdapter (android.widget.ArrayAdapter)21 Point (android.graphics.Point)19 SuppressLint (android.annotation.SuppressLint)16 SimpleCursorAdapter (android.widget.SimpleCursorAdapter)16 Cursor (android.database.Cursor)12 SectionIndexer (android.widget.SectionIndexer)11 DialogInterface (android.content.DialogInterface)10 Bundle (android.os.Bundle)10 FrameLayout (android.widget.FrameLayout)10 GridView (android.widget.GridView)10