Search in sources :

Example 11 with ListAdapter

use of android.widget.ListAdapter in project android by owncloud.

the class ShareFileFragment method setListViewHeightBasedOnChildren.

public static void setListViewHeightBasedOnChildren(ListView listView) {
    ListAdapter listAdapter = listView.getAdapter();
    if (listAdapter == null) {
        return;
    }
    int desiredWidth = View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.AT_MOST);
    int totalHeight = 0;
    View view = null;
    for (int i = 0; i < listAdapter.getCount(); i++) {
        view = listAdapter.getView(i, view, listView);
        if (i == 0) {
            view.setLayoutParams(new ViewGroup.LayoutParams(desiredWidth, ViewGroup.LayoutParams.WRAP_CONTENT));
        }
        view.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);
        totalHeight += view.getMeasuredHeight();
    }
    ViewGroup.LayoutParams params = listView.getLayoutParams();
    params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
    listView.setLayoutParams(params);
    listView.requestLayout();
}
Also used : ViewGroup(android.view.ViewGroup) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) ListView(android.widget.ListView) ShareUserListAdapter(com.owncloud.android.ui.adapter.ShareUserListAdapter) ListAdapter(android.widget.ListAdapter)

Example 12 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 13 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 14 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)

Example 15 with ListAdapter

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

the class ListWithHeaders method onCreate.

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    final ListView listView = getListView();
    listView.setItemsCanFocus(true);
    for (int i = 0; i < 12; i++) {
        Button header = new Button(this);
        header.setText("Header View");
        listView.addHeaderView(header);
    }
    for (int i = 0; i < 12; i++) {
        Button footer = new Button(this);
        footer.setText("Footer View");
        listView.addFooterView(footer);
    }
    final ListAdapter adapter = listView.getAdapter();
    listView.setAdapter(adapter);
}
Also used : ListView(android.widget.ListView) Button(android.widget.Button) ListAdapter(android.widget.ListAdapter)

Aggregations

ListAdapter (android.widget.ListAdapter)441 View (android.view.View)151 ListView (android.widget.ListView)144 ViewGroup (android.view.ViewGroup)75 WrapperListAdapter (android.widget.WrapperListAdapter)72 TextView (android.widget.TextView)70 AdapterView (android.widget.AdapterView)68 AbsListView (android.widget.AbsListView)66 HeaderViewListAdapter (android.widget.HeaderViewListAdapter)47 Paint (android.graphics.Paint)32 Point (android.graphics.Point)30 ArrayAdapter (android.widget.ArrayAdapter)30 ImageView (android.widget.ImageView)25 ArrayList (java.util.ArrayList)24 SuppressLint (android.annotation.SuppressLint)23 FrameLayout (android.widget.FrameLayout)20 DialogInterface (android.content.DialogInterface)18 GridView (android.widget.GridView)17 BaseAdapter (android.widget.BaseAdapter)16 SimpleCursorAdapter (android.widget.SimpleCursorAdapter)16