Search in sources :

Example 86 with ListAdapter

use of android.widget.ListAdapter in project UltimateAndroid by cymcsg.

the class ActivityTransitionActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_transition_first);
    ListView list = (ListView) this.findViewById(R.id.listView);
    ListAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, _animationList);
    list.setAdapter(adapter);
    list.setOnItemClickListener(this);
}
Also used : ListView(android.widget.ListView) ListAdapter(android.widget.ListAdapter) ArrayAdapter(android.widget.ArrayAdapter)

Example 87 with ListAdapter

use of android.widget.ListAdapter in project UltimateAndroid by cymcsg.

the class DragSortListView method getChildHeight.

private int getChildHeight(int position) {
    if (position == mSrcPos) {
        return 0;
    }
    View v = getChildAt(position - getFirstVisiblePosition());
    if (v != null) {
        // hence the "true"
        return getChildHeight(position, v, false);
    } else {
        // item is offscreen
        // first check cache for child height at this position
        int childHeight = mChildHeightCache.get(position);
        if (childHeight != -1) {
            // Log.d("mobeta", "found child height in cache!");
            return childHeight;
        }
        final ListAdapter adapter = getAdapter();
        int type = adapter.getItemViewType(position);
        // There might be a better place for checking for the following
        final int typeCount = adapter.getViewTypeCount();
        if (typeCount != mSampleViewTypes.length) {
            mSampleViewTypes = new View[typeCount];
        }
        if (type >= 0) {
            if (mSampleViewTypes[type] == null) {
                v = adapter.getView(position, null, this);
                mSampleViewTypes[type] = v;
            } else {
                v = adapter.getView(position, mSampleViewTypes[type], this);
            }
        } else {
            // type is HEADER_OR_FOOTER or IGNORE
            v = adapter.getView(position, null, this);
        }
        // current child height is invalid, hence "true" below
        childHeight = getChildHeight(position, v, true);
        // cache it because this could have been expensive
        mChildHeightCache.add(position, childHeight);
        return childHeight;
    }
}
Also used : View(android.view.View) ListView(android.widget.ListView) Point(android.graphics.Point) ListAdapter(android.widget.ListAdapter)

Example 88 with ListAdapter

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

the class LoadPackagesAsyncTask method onPostExecute.

@Override
protected void onPostExecute(final List<AppInfo> results) {
    ListAdapter listAdapter = new ArrayAdapter<AppInfo>(activity, R.layout.app_picker_list_item, R.id.app_picker_list_item_label, results) {

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view = super.getView(position, convertView, parent);
            Drawable icon = results.get(position).getIcon();
            if (icon != null) {
                ((ImageView) view.findViewById(R.id.app_picker_list_item_icon)).setImageDrawable(icon);
            }
            return view;
        }
    };
    activity.setListAdapter(listAdapter);
}
Also used : ViewGroup(android.view.ViewGroup) Drawable(android.graphics.drawable.Drawable) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) ListAdapter(android.widget.ListAdapter) ArrayAdapter(android.widget.ArrayAdapter)

Example 89 with ListAdapter

use of android.widget.ListAdapter in project SeaStar by 13120241790.

the class PullToRefreshListView method onRefreshing.

@Override
protected void onRefreshing(final boolean doScroll) {
    /**
		 * If we're not showing the Refreshing view, or the list is empty, the
		 * the header/footer views won't show so we use the normal method.
		 */
    ListAdapter adapter = mRefreshableView.getAdapter();
    if (!mListViewExtrasEnabled || !getShowViewWhileRefreshing() || null == adapter || adapter.isEmpty()) {
        super.onRefreshing(doScroll);
        return;
    }
    super.onRefreshing(false);
    final LoadingLayout origLoadingView, listViewLoadingView, oppositeListViewLoadingView;
    final int selection, scrollToY;
    switch(getCurrentMode()) {
        case MANUAL_REFRESH_ONLY:
        case PULL_FROM_END:
            origLoadingView = getFooterLayout();
            listViewLoadingView = mFooterLoadingView;
            oppositeListViewLoadingView = mHeaderLoadingView;
            selection = mRefreshableView.getCount() - 1;
            scrollToY = getScrollY() - getFooterSize();
            break;
        case PULL_FROM_START:
        default:
            origLoadingView = getHeaderLayout();
            listViewLoadingView = mHeaderLoadingView;
            oppositeListViewLoadingView = mFooterLoadingView;
            selection = 0;
            scrollToY = getScrollY() + getHeaderSize();
            break;
    }
    // Hide our original Loading View
    origLoadingView.reset();
    origLoadingView.hideAllViews();
    // Make sure the opposite end is hidden too
    oppositeListViewLoadingView.setVisibility(View.GONE);
    // Show the ListView Loading View and set it to refresh.
    listViewLoadingView.setVisibility(View.VISIBLE);
    listViewLoadingView.refreshing();
    if (doScroll) {
        // We need to disable the automatic visibility changes for now
        disableLoadingLayoutVisibilityChanges();
        // We scroll slightly so that the ListView's header/footer is at the
        // same Y position as our normal header/footer
        setHeaderScroll(scrollToY);
        // Make sure the ListView is scrolled to show the loading
        // header/footer
        mRefreshableView.setSelection(selection);
        // Smooth scroll as normal
        smoothScrollTo(0);
    }
}
Also used : ListAdapter(android.widget.ListAdapter) LoadingLayout(com.rongseal.widget.pulltorefresh.internal.LoadingLayout)

Example 90 with ListAdapter

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

the class SyncActivityTooManyDeletes method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle extras = getIntent().getExtras();
    if (extras == null) {
        finish();
        return;
    }
    mNumDeletes = extras.getLong("numDeletes");
    mAccount = (Account) extras.getParcelable("account");
    mAuthority = extras.getString("authority");
    mProvider = extras.getString("provider");
    // the order of these must match up with the constants for position used in onItemClick
    CharSequence[] options = new CharSequence[] { getResources().getText(R.string.sync_really_delete), getResources().getText(R.string.sync_undo_deletes), getResources().getText(R.string.sync_do_nothing) };
    ListAdapter adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_list_item_1, android.R.id.text1, options);
    ListView listView = new ListView(this);
    listView.setAdapter(adapter);
    listView.setItemsCanFocus(true);
    listView.setOnItemClickListener(this);
    TextView textView = new TextView(this);
    CharSequence tooManyDeletesDescFormat = getResources().getText(R.string.sync_too_many_deletes_desc);
    textView.setText(String.format(tooManyDeletesDescFormat.toString(), mNumDeletes, mProvider, mAccount.name));
    final LinearLayout ll = new LinearLayout(this);
    ll.setOrientation(LinearLayout.VERTICAL);
    final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0);
    ll.addView(textView, lp);
    ll.addView(listView, lp);
    // TODO: consider displaying the icon of the account type
    //        AuthenticatorDescription[] descs = AccountManager.get(this).getAuthenticatorTypes();
    //        for (AuthenticatorDescription desc : descs) {
    //            if (desc.type.equals(mAccount.type)) {
    //                try {
    //                    final Context authContext = createPackageContext(desc.packageName, 0);
    //                    ImageView imageView = new ImageView(this);
    //                    imageView.setImageDrawable(authContext.getDrawable(desc.iconId));
    //                    ll.addView(imageView, lp);
    //                } catch (PackageManager.NameNotFoundException e) {
    //                }
    //                break;
    //            }
    //        }
    setContentView(ll);
}
Also used : ListView(android.widget.ListView) Bundle(android.os.Bundle) TextView(android.widget.TextView) ListAdapter(android.widget.ListAdapter) ArrayAdapter(android.widget.ArrayAdapter) LinearLayout(android.widget.LinearLayout)

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