Search in sources :

Example 26 with AbsListView

use of android.widget.AbsListView in project AndroidPicker by gzu-liyujiang.

the class PathAdapter method getView.

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    final Context context = parent.getContext();
    ViewHolder holder;
    if (convertView == null) {
        int matchParent = ViewGroup.LayoutParams.MATCH_PARENT;
        int wrapContent = ViewGroup.LayoutParams.WRAP_CONTENT;
        LinearLayout layout = new LinearLayout(context);
        layout.setOrientation(LinearLayout.HORIZONTAL);
        layout.setGravity(Gravity.CENTER_VERTICAL);
        // fixed: 17-1-8 #79 安卓4.x兼容问题,java.lang.ClassCastException……onMeasure……
        if (parent instanceof AbsListView) {
            layout.setLayoutParams(new AbsListView.LayoutParams(matchParent, matchParent));
        } else {
            layout.setLayoutParams(new ViewGroup.LayoutParams(matchParent, matchParent));
        }
        TextView textView = new TextView(context);
        LinearLayout.LayoutParams tvParams = new LinearLayout.LayoutParams(wrapContent, matchParent);
        textView.setLayoutParams(tvParams);
        textView.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
        int padding = ConvertUtils.toPx(context, 5);
        textView.setPadding(padding, 0, padding, 0);
        layout.addView(textView);
        ImageView imageView = new ImageView(context);
        int width = ConvertUtils.toPx(context, 20);
        imageView.setLayoutParams(new LinearLayout.LayoutParams(width, matchParent));
        imageView.setImageResource(android.R.drawable.ic_menu_report_image);
        layout.addView(imageView);
        convertView = layout;
        holder = new ViewHolder();
        holder.textView = textView;
        holder.imageView = imageView;
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    holder.textView.setText(paths.get(position));
    holder.imageView.setImageDrawable(arrowIcon);
    return convertView;
}
Also used : Context(android.content.Context) ViewGroup(android.view.ViewGroup) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout)

Example 27 with AbsListView

use of android.widget.AbsListView in project TwinklingRefreshLayout by lcodecorex.

the class ScrollingUtil method scrollAViewBy.

public static void scrollAViewBy(View view, int height) {
    if (view instanceof RecyclerView)
        ((RecyclerView) view).scrollBy(0, height);
    else if (view instanceof ScrollView)
        ((ScrollView) view).smoothScrollBy(0, height);
    else if (view instanceof AbsListView)
        ((AbsListView) view).smoothScrollBy(height, 0);
    else {
        try {
            Method method = view.getClass().getDeclaredMethod("smoothScrollBy", Integer.class, Integer.class);
            method.invoke(view, 0, height);
        } catch (Exception e) {
            view.scrollBy(0, height);
        }
    }
}
Also used : ScrollView(android.widget.ScrollView) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) Method(java.lang.reflect.Method)

Example 28 with AbsListView

use of android.widget.AbsListView in project AndroidPicker by gzu-liyujiang.

the class WheelView method onScrollStateChanged.

@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    if (scrollState != SCROLL_STATE_IDLE) {
        return;
    }
    View itemView = getChildAt(0);
    if (itemView == null) {
        return;
    }
    float deltaY = itemView.getY();
    // fixed: 17-1-7  Equality tests should not be made with floating point values.
    if ((int) deltaY == 0 || itemHeightPixels == 0) {
        return;
    }
    if (Math.abs(deltaY) < itemHeightPixels / 2) {
        int d = obtainSmoothDistance(deltaY);
        smoothScrollBy(d, SMOOTH_SCROLL_DURATION);
    } else {
        int d = obtainSmoothDistance(itemHeightPixels + deltaY);
        smoothScrollBy(d, SMOOTH_SCROLL_DURATION);
    }
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ListView(android.widget.ListView) Paint(android.graphics.Paint)

Example 29 with AbsListView

use of android.widget.AbsListView in project AndroidPicker by gzu-liyujiang.

the class ImageAdapter method getView.

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder viewHolder;
    if (convertView == null) {
        viewHolder = new ViewHolder();
        convertView = new ImageView(context);
        ViewGroup.LayoutParams params;
        if (parent instanceof AbsListView) {
            //java.lang.ClassCastException:
            // android.view.ViewGroup$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
            params = new AbsListView.LayoutParams(width, height);
        } else {
            params = new ViewGroup.LayoutParams(width, height);
        }
        convertView.setLayoutParams(params);
        viewHolder.imageView = (ImageView) convertView;
        viewHolder.imageView.setScaleType(scaleType);
        //加上key,避免和Glide框架冲突: You must not call setTag() on a view Glide is targeting
        convertView.setTag(TAG_KEY_AVOID_CONFLICT_WITH_GLIDE, viewHolder);
    } else {
        viewHolder = (ViewHolder) convertView.getTag(TAG_KEY_AVOID_CONFLICT_WITH_GLIDE);
    }
    final Object item = data.get(position);
    viewHolder.imageView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (onImageClickListener != null) {
                onImageClickListener.onImageClick(position, item);
            }
        }
    });
    switch(mode) {
        case INTEGER:
            viewHolder.imageView.setImageResource((Integer) item);
            break;
        case DRAWABLE:
            viewHolder.imageView.setImageDrawable((Drawable) item);
            break;
        case BITMAP:
            viewHolder.imageView.setImageBitmap((Bitmap) item);
            break;
        default:
            ImageHelper.getInstance().display(item.toString(), viewHolder.imageView, width, height);
            break;
    }
    return convertView;
}
Also used : ViewGroup(android.view.ViewGroup) AbsListView(android.widget.AbsListView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) AbsListView(android.widget.AbsListView)

Example 30 with AbsListView

use of android.widget.AbsListView in project platform_frameworks_base by android.

the class ResolverActivity method onPrepareAdapterView.

public void onPrepareAdapterView(AbsListView adapterView, ResolveListAdapter adapter, boolean alwaysUseOption) {
    final boolean useHeader = adapter.hasFilteredItem();
    final ListView listView = adapterView instanceof ListView ? (ListView) adapterView : null;
    adapterView.setAdapter(mAdapter);
    final ItemClickListener listener = new ItemClickListener();
    adapterView.setOnItemClickListener(listener);
    adapterView.setOnItemLongClickListener(listener);
    if (alwaysUseOption) {
        listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
    }
    if (useHeader && listView != null) {
        listView.addHeaderView(LayoutInflater.from(this).inflate(R.layout.resolver_different_item_header, listView, false));
    }
}
Also used : ListView(android.widget.ListView) AbsListView(android.widget.AbsListView)

Aggregations

AbsListView (android.widget.AbsListView)218 View (android.view.View)126 ListView (android.widget.ListView)80 AdapterView (android.widget.AdapterView)54 TextView (android.widget.TextView)46 ViewGroup (android.view.ViewGroup)33 ImageView (android.widget.ImageView)29 RecyclerView (android.support.v7.widget.RecyclerView)21 GridView (android.widget.GridView)21 SuppressLint (android.annotation.SuppressLint)20 ScrollView (android.widget.ScrollView)20 OnScrollListener (android.widget.AbsListView.OnScrollListener)19 Intent (android.content.Intent)17 ArrayList (java.util.ArrayList)16 Context (android.content.Context)12 Point (android.graphics.Point)12 Handler (android.os.Handler)12 ExpandableListView (android.widget.ExpandableListView)12 ArrayListLoader (com.klinker.android.twitter.adapters.ArrayListLoader)10 ItemManager (org.lucasr.smoothie.ItemManager)10