Code Monkey home page Code Monkey logo

horizontalvariablelistview's Introduction

Deprecated

This widget is now deprecated and it won't be updated anymore. Use RecyclerView instead

Horizontal Variable ListView

Horizontal ListView for Android. Based on the official ListView google code. The library includes also an ExpandableHListView, also based on the official ExpandableListView.
See the demo project for sample implementations

Usage (gradle)

Add this line to your dependency group:

compile 'it.sephiroth.android.library.horizontallistview:hlistview:1.2.2'

Features

It supports almost all the features of the ListView widget. There are minor differences in the attributes supported like "hlv_dividerWidth" instead of the default "dividerHeight".

This is the styleable used for the HListView class:

    <declare-styleable name="HListView">
        <attr name="android:entries" />
        <attr name="android:divider" />
        <attr name="hlv_dividerWidth" format="dimension" />
        <attr name="hlv_headerDividersEnabled" format="boolean" />
        <attr name="hlv_footerDividersEnabled" format="boolean" />
        <attr name="hlv_overScrollHeader" format="reference|color" />
        <attr name="hlv_overScrollFooter" format="reference|color" />
        
        <!-- 
        When "wrap_content" is used as value of the layout_height property.
        Pass the position, inside the adapter, of the view being used to measure the view
        or '-1' to use the default behavior ( default is -1 )
        -->
        <attr name="hlv_measureWithChild" format="integer" />
    </declare-styleable>
    

    <declare-styleable name="AbsHListView">
        <attr name="android:listSelector" />
        <attr name="android:smoothScrollbar" />
        <attr name="android:drawSelectorOnTop" />
        <attr name="android:cacheColorHint" />
        <attr name="android:scrollingCache" />
        <attr name="android:choiceMode" />
        
        <attr name="hlv_stackFromRight" format="boolean" />
        <attr name="hlv_transcriptMode">
            <enum name="disabled" value="0"/>
            <enum name="normal" value="1" />
            <enum name="alwaysScroll" value="2" />
        </attr>
        
    </declare-styleable>  

ChangeLog

  • 1.2.0 Added the ExpandableHListView

API Requirements

The minimum supported Android version is android 2.3 (API Level 9)

License

This software is distributed under Apache License 2.0: http://www.apache.org/licenses/LICENSE-2.0


Author Alessandro Crugnola

horizontalvariablelistview's People

Contributors

acappelli avatar berglund avatar braisgabin avatar sephiroth74 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

horizontalvariablelistview's Issues

Can't use custom attributes in XML

I have the following layout

   <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/background_gray"
        android:focusableInTouchMode="true"
        >
                <it.sephiroth.android.library.widget.HListView
                    android:id="@+id/storefront_gallery_list"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/gallery_image_side"
                    android:divider="@android:color/transparent"
                    app:dividerWidth="@dimen/spacing_normal"
                    android:paddingTop="@dimen/spacing_normal"
                    android:background="@color/background_gray"
                    />
    </RelativeLayout>

I'm no longer able to compile this. I get the following Gradle error:

Output:
/Users/user/dev/mobile/test-project/TestProj/build/res/all/debug/layout/activity_test.xml:123: error: No resource identifier found for attribute 'dividerWidth' in package 'com.test.testproj'

There seems to be an issue with

app:dividerWidth="@dimen/spacing_normal"

and

xmlns:app="http://schemas.android.com/apk/res-auto"

Should I be including that a different way? I ended up having to programmatically set the dividerWidth attribute. This started happening not too long ago. I had to clean my gradle cache ~/.gradle and maven cache ~/.m2 for it to manifest itself on my local machine in case that's of relevance.

Question: how to scroll programmatically?

Hi, I wanted to ask is there something similar like AbsListView.smoothScrollBy?

I went through the code but didn't found any obvious way to scroll view programmatically.

My goal is to add some automatic scrolling when user finish it's manual scrolling to adjust alignment of the items, so the first I item will be fully visible (not half of a view).

Thank you for any answers.

Snap To Item and bubbling vertical touch events to parent view (or parent listview)

Hi,

Just wondering if this is possible with the HorizontalListView class? Also, I have the HorizontalVariableListView inside a regular ListView - I wanted to know how I can send the up and down touch/scroll events to the parent ListView - currently - if I try and scroll the main (parent) listview up and down while touching somewhere inside the HorizontalVariableListView the touch seems to be lost and nothing happens - if that event (if you can tell me what and how to get the event even) can be trapped and somehow bubbled up to the parent listView that would be great.

Thanks for an excellent library,

Warm Regards,

Shabbir

JAR file for download?

Would it be possible to get a JAR file for this rather than copying all the source files into my project?

how to smooth scroll to specified position of the adapter in development branch

I use the development branch in my project to realize the horizontal listview. But,when I invoke the notifyDataSetReplaced and notifyDataSetAdded how I can smooth scroll to specified position of the adapter in development branch. I just want the specified position view show in the first position of the visible rectใ€‚I will be happy to getting your help, thanks a lot.

ClassCastException - Adding a Footer

In my application I have a number of fragments, most of which contain a ListView, including one with an HListView. There are two paths to the fragment with the HListView - one works without issue, and the other throws a ClassCastException. I've spent several hours trying to figure out the cause, but I can't find an answer in my code. I am not importing either of these LayoutParams, and I've made sure the ids of the layouts and layout objects are unique. Below is the log which captures the exception. Any ideas?

FATAL EXCEPTION: main
java.lang.ClassCastException: android.widget.AbsListView$LayoutParams cannot be cast to it.sephiroth.android.library.widget.AbsHListView$LayoutParams
at it.sephiroth.android.library.widget.HListView.clearRecycledState(HListView.java:506)
at it.sephiroth.android.library.widget.HListView.resetList(HListView.java:493)
at it.sephiroth.android.library.widget.HListView.layoutChildren(HListView.java:1560)
at it.sephiroth.android.library.widget.AbsHListView.onLayout(AbsHListView.java:1676)
at android.view.View.layout(View.java:14016)
at android.view.ViewGroup.layout(ViewGroup.java:4647)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:948)
at android.view.View.layout(View.java:14016)
at android.view.ViewGroup.layout(ViewGroup.java:4647)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14016)
at android.view.ViewGroup.layout(ViewGroup.java:4647)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14016)
at android.view.ViewGroup.layout(ViewGroup.java:4647)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14016)
at android.view.ViewGroup.layout(ViewGroup.java:4647)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
at android.view.View.layout(View.java:14016)
at android.view.ViewGroup.layout(ViewGroup.java:4647)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14016)
at android.view.ViewGroup.layout(ViewGroup.java:4647)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1879)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1700)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1005)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4243)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4777)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:998)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:765)
at dalvik.system.NativeStart.main(Native Method)

Question: smoothScrollTo?

Could you please add smoothScrollTo method in your Demo code?

I changed the followings in your demo code:

  1. change item width to 100px in view1.xml
  2. I want to scroll to the 31th item, so in the MainActivity.java added the following line at the end of onCreate method, then the scroll bar is empty now.

mList.smoothScrollTo(30*100);

ScrollTo does not work correctly

scrollTo properly scrolls to the correct position but does not request views from the newly visible adapter items. For the time being I have overridden scrollTo to forward to smoothScrollBy with a duration of 0.

OnItemClicked doesn't fire

Hey all,

First of all, i want to thank you Alessandro for this lovely component. I have also tested the dev-smart's HorizontalListView, and i am getting much better results with your view.

Unfortunately though, I am suffering from one main problem - while i can scroll nice and smooth, i can't catch onItemClicked events. I have followed the example you've provided in the demo activity. More frustrating is the fact that when i test the same views and layouts i am using, with android's native ListView, and dev-smart's HLV it actually works. I made sure i was using the correct classed, but still can't get it to work.

Would appreciate if you guys could take a look at my code, and see whether i am doing something terribly catastrophic. After looking at it for the entire day, i am positive i am missing something very fundamental

The element view:

<ImageView 
    android:id="@+id/channel_slide_thumbnail_bg"
    android:layout_width="134dp"
    android:layout_height="134dp"
    android:clickable="false"
    android:background="@drawable/thumb_fpo_223x223" />

<ImageView
    android:id="@+id/channel_slide_thumbnail_photo"
    android:layout_width="132dp"
    android:layout_height="132dp"
    android:layout_alignLeft="@+id/channel_slide_thumbnail_bg"
    android:layout_alignTop="@+id/channel_slide_thumbnail_bg"
    android:layout_marginLeft="1dp"
    android:layout_marginTop="1dp"
    android:adjustViewBounds="true" 
    android:scaleType="fitCenter"/>

<ImageView
    android:id="@+id/channel_slide_thumbnail_header"
    android:layout_width="134dp"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/channel_slide_thumbnail_bg"
    android:layout_alignTop="@+id/channel_slide_thumbnail_bg"        
    android:background="@drawable/header_thumb_channel" />

<TextView 
    android:id="@+id/channel_slide_thumbnail_channel_name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/channel_slide_thumbnail_header"
    android:layout_alignLeft="@+id/channel_slide_thumbnail_header"
    android:layout_marginLeft="6dp"
    android:textSize="12sp"
    android:textColor="@color/white"/>

<TextView 
    android:id="@+id/channel_slide_thumbnail_viewer_number"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/channel_slide_thumbnail_header"
    android:layout_alignRight="@+id/channel_slide_thumbnail_header"
    android:layout_marginRight="6dp"
    android:textSize="12sp"/>

HVLV's container

<RelativeLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content">       

    <ImageView 
        android:id="@+id/slide_menus_background"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/back_home" />

    <ImageView 
        android:id="@+id/slide_menus_recommended_subheader"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/subheader_channels" />

    <TextView 
        android:id="@+id/slide_menus_recommended_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/slide_menus_recommended_subheader"
        android:layout_marginLeft="@dimen/slider_subheader_horizontal_margin"
        android:layout_marginBottom="@dimen/slider_subheader_vertical_margin"
        android:text="@string/recommended_label" />

    <it.sephiroth.android.library.widget.HorizontalVariableListView
        android:id="@+id/slide_menus_recommended_slider"
        android:layout_width="fill_parent"
        android:layout_height="134dp"
        android:layout_below="@+id/slide_menus_recommended_subheader" />

    <ImageView 
        android:id="@+id/slide_menus_talk_subheader"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/slide_menus_recommended_slider"
        android:background="@drawable/subheader_channels" />

    <TextView 
        android:id="@+id/slide_menus_talk_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/slide_menus_talk_subheader"
        android:layout_marginLeft="@dimen/slider_subheader_horizontal_margin"
        android:layout_marginBottom="@dimen/slider_subheader_vertical_margin"
        android:text="@string/talk_label" />

    <it.sephiroth.android.library.widget.HorizontalVariableListView
        android:id="@+id/slide_menus_talk_slider"
        android:layout_width="fill_parent"
        android:layout_height="134dp"
        android:layout_below="@+id/slide_menus_talk_subheader" />

</RelativeLayout>

Element adapter

public class ChannelSlideThumbnailsAdapter extends BaseAdapter {

private Activity activity;
private List<ChannelSlideData> channelsSlideData;
private static LayoutInflater inflater=null;

public ChannelSlideThumbnailsAdapter(Activity a, List<ChannelSlideData> channelsSlideData) {
    activity = a;
    this.channelsSlideData = channelsSlideData;
    inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

public int getCount() {
    return channelsSlideData.size();
}

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

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

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    View vi = convertView;
    if(convertView==null)
        vi = inflater.inflate(R.layout.view_channelslidethumbnail, null);

    ImageView channelPhoto = (ImageView) vi.findViewById(R.id.channel_slide_thumbnail_photo);
    TextView channelName = (TextView)vi.findViewById(R.id.channel_slide_thumbnail_channel_name);
    TextView channelViewersNumber = (TextView)vi.findViewById(R.id.channel_slide_thumbnail_viewer_number);

    ChannelSlideData channelSlideData = channelsSlideData.get(position);

    // load image
    try {
        // get input stream
        InputStream ims = activity.getAssets().open(channelSlideData.avatarUrl);
        // load image as Drawable
        Drawable d = Drawable.createFromStream(ims, null);
        // set image to ImageView
        channelPhoto.setImageDrawable(d);            
    }
    catch(IOException ex) {
        // TODO - what should be done here?
    }

    channelName.setText(channelSlideData.channelName);
    channelViewersNumber.setText(Integer.toString(channelSlideData.viewersNo));

    return vi;
}

}


View creation:

mRecommendedSlide = (HorizontalVariableListView) getActivity().findViewById(R.id.slide_menus_recommended_slider);

    final List<ChannelSlideData> channelSlideThumbnailsData = new ArrayList<ChannelSlideData>();
    ChannelSlideData channelSlideData;

    for (int i=0; i < 10 ; i++) {
        channelSlideData = new ChannelSlideData();      
        channelSlideData.avatarUrl = "images/camel.png";
        channelSlideData.channelName = "Shows";
        channelSlideData.viewersNo = 1000;
        channelSlideThumbnailsData.add(channelSlideData);
    }

    ChannelSlideThumbnailsAdapter adapter = new ChannelSlideThumbnailsAdapter(getActivity(), channelSlideThumbnailsData);
    mRecommendedSlide.setOverScrollMode( HorizontalVariableListView.OVER_SCROLL_ALWAYS );
    mRecommendedSlide.setAdapter(adapter);

    // Click event for single list row
    mRecommendedSlide.setOnItemClickedListener( new OnItemClickedListener() {

        @Override
        public boolean onItemClick( AdapterView<?> parent, View view, int position, long id ) {
            Log.e( TAG_LOG, "onItemClick: " + position );
            return true;
        }
    });

Would appreciate any help with this.

Thanks,
K

API 8 support

Hi, what is the reason this library support only android 2.3+ ?
Is there any chance to add support for android 2.2 too?

How to set cell selected colour?

I am having trouble setting the cell selected colour.

I have tried in XML by setting the listSelector attribute as follows:

        android:listSelector="@drawable/selected_background"

The selected_background is a simple shape containing a solid colour

Unfortunately the item selected colour is still the standard Holo Light blue.

It seems in the standard ListView there is a setSelector method. However, this does not seem to be included in the HVLV.

I must be missing something very simple.... :)

Broken build

I was unable to build event Demo project via ant build (debug target).

Root cause of error was strange:
.......
clean:
[getlibpath] Library dependencies:
[getlibpath]
[getlibpath] ------------------
[getlibpath] Ordered libraries:

BUILD FAILED
/Users/ak/Development/android-sdk-macosx/tools/ant/build.xml:471: The following error occurred while executing this line:
/Users/ak/Downloads/HorizontalVariableListView-master/HorizontalVariableListView/build.xml:50: Source resource does not exist: /Users/ak/Downloads/project.properties

SOLUTION that I've researched:
Please remove entry
<loadproperties srcFile="../../project.properties" />

from this file:
HorizontalVariableListView/build.xml:50

Lint warning: Scroll image density

The image hlv_overscroll_edge.png varies significantly in its density-independent (dip) size across the various density versions: drawable-mdpi/hlv_overscroll_edge.png: 522x12 dp (522x12 px), drawable-xhdpi/hlv_overscroll_edge.png: 522x12 dp (1044x24 px), drawable-hdpi/hlv_overscroll_edge.png: 522x12 dp (783x18 px), drawable-ldpi/hlv_overscroll_edge.png: 320x11 dp (240x8 px)

notifyDataSetChanged() scrolls HorizontalVariableListView to beginning.

Invoking notifyDataSetChanged() changes position in HorizontalVariableListView to 0. If I remember normal ListView remembers scroll state.

I think the problem is caused by:

/** The m data observer. */
private DataSetObserver mDataObserver = new DataSetObserver() {

    @Override
    public void onChanged() {
        synchronized ( HorizontalVariableListView.this ) {
            mAdapterItemCount = mAdapter.getCount();
        }
        Log.i( LOG_TAG, "onChanged(2): " + mAdapterItemCount );
        invalidate();
        reset();
    }

    @Override
    public void onInvalidated() {
        mAdapterItemCount = mAdapter.getCount();
        Log.i( LOG_TAG, "onInvalidated(2): " + mAdapterItemCount );
        invalidate();
        reset();
    }
};

and:

/**
 * Reset.
 */
private synchronized void reset() {
    mCurrentX = 0;
    initView();
    removeAllViewsInLayout();
    mForceLayout = true;
    requestLayout();
}

how to change it so position is kept?

picture width are not variable

Hello,

I'm trying to implement a HorizontalVariableListView with static hights and variable width of the Images. But the width of the ImageView ( from "detail_view.xml") is the same for the whole list.

It seams that the width is calculatetd/mesured from the first child in the list and all other childs have the same width --> the images are croped...

Can you help me with this issue.
Thanks in advance!

Listview with items as HListView

I have normal listview. Listview don't have divider. For test, bind each item listview with colored textview (red and blue). All ok. Don't see vertical divider between items.
Next: render at each listview item HListView (as with TextView also set background for HListView: red/blue). And now see some bottom padding at each item. Why?
hlistview_bottom_padding
.

layout_height="match_parent" is not supported

if the item of the list has layout_height="match_parent" is behaving like "wrap_content".

I found a hack to fix until is not fixed in the library.

if you use a RelativeLayout as wrapper with layout_height="match_parent", it is working then.

move up and down

Hi,

I use HorizontalVariableListView inside scrollview.It can't move up and down at the touch horizanallistview.

regard
Kit

Error with getViewTypeCount() IndexOutOfBoundsException

When I use BadeAdapter and override getViewTypeCount() and getItemViewType() in this way:

@Override
public int getItemViewType(int position) {
    return position;
}
@Override
public int getViewTypeCount() {
    items.size() 
}

Then I get an error:

06-28 14:36:36.242: E/AndroidRuntime(3959): FATAL EXCEPTION: main
06-28 14:36:36.242: E/AndroidRuntime(3959): java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
06-28 14:36:36.242: E/AndroidRuntime(3959): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
06-28 14:36:36.242: E/AndroidRuntime(3959): at java.util.ArrayList.get(ArrayList.java:311)
06-28 14:36:36.242: E/AndroidRuntime(3959): at java.util.Collections$SynchronizedList.get(Collections.java:584)
06-28 14:36:36.242: E/AndroidRuntime(3959): at it.sephiroth.android.library.widget.HorizontalVariableListView.fillListRight(HorizontalVariableListView.java:824)
06-28 14:36:36.242: E/AndroidRuntime(3959): at it.sephiroth.android.library.widget.HorizontalVariableListView.fillList(HorizontalVariableListView.java:704)
06-28 14:36:36.242: E/AndroidRuntime(3959): at it.sephiroth.android.library.widget.HorizontalVariableListView.trackMotionScroll(HorizontalVariableListView.java:251)
06-28 14:36:36.242: E/AndroidRuntime(3959): at it.sephiroth.android.library.widget.IFlingRunnable.run(IFlingRunnable.java:78)
06-28 14:36:36.242: E/AndroidRuntime(3959): at android.os.Handler.handleCallback(Handler.java:587)
06-28 14:36:36.242: E/AndroidRuntime(3959): at android.os.Handler.dispatchMessage(Handler.java:92)
06-28 14:36:36.242: E/AndroidRuntime(3959): at android.os.Looper.loop(Looper.java:123)
06-28 14:36:36.242: E/AndroidRuntime(3959): at android.app.ActivityThread.main(ActivityThread.java:4627)
06-28 14:36:36.242: E/AndroidRuntime(3959): at java.lang.reflect.Method.invokeNative(Native Method)
06-28 14:36:36.242: E/AndroidRuntime(3959): at java.lang.reflect.Method.invoke(Method.java:521)
06-28 14:36:36.242: E/AndroidRuntime(3959): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
06-28 14:36:36.242: E/AndroidRuntime(3959): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
06-28 14:36:36.242: E/AndroidRuntime(3959): at dalvik.system.NativeStart.main(Native Method)

I suspect that library stores old value of getViewTypeCount() and doesn't update it after notifyDataSetChanged();

D-Pad/Trackpad support

I am trying to use this widget in a Google TV project stacking HorizontalListViews one on top of another. I can't seem to get the Demo to work with trackpad/D-pad that google tv supports.
Ideally d-pad should cause the items to get focus and left/right should scroll the list horizontally.

Memory management of HorizontalVariableListView

I have a lot of large Images in my HorizontalVariableListView.

I debugged my App with DDMS Logcat and i see that the memory is continusliy growing when scrolling trough the list (this is of course, becaus the other images get lazy loaded). But in the official Android List View, the elements that are outside the screen (at least - that are a certain amout of space away from the screen bounds) are deleted/recycled from memory.

How can I achieve this with HorizontalVariableListView?
Beacuse soon or later I will run into a OutOfMemory Exeption.

Thanks for support!

Filter items in list

Hello,

I have a problem filtering the list. If for example I have a 200 elements list and I filter it to 10 notifying the adapter all works well only that when fling to the end of the list it scroll way over the end of the list in white space.

Thank you.

ClassCastException occurs when App Package is different than the R.java package

The Android Gradle Plugin allows you to rename the App package, which is convenient for installing your debug and release apps on the same device.

I've traced it down to this line: https://github.com/sephiroth74/HorizontalVariableListView/blob/master/library/src/it/sephiroth/android/library/widget/AbsHListView.java#L5794

See https://groups.google.com/forum/?fromgroups=#!topic/adt-dev/cqdjG2TuM-I

from Xavier Ducrohet:

They make the assumption that the package name of the app is the same as the R class. This really is not correct. While the previous build system somewhat implied this, aapt always had the feature to generate the R class in a different package.

Thinking about it there really is no current way to query the app for the package of the R class. It'd have to be provided to the library.

problem with wrap_content in layout_height param

Hello
I try to set layout_height = wrap_content to the horizontalvariablelistview who content only one listview and is not work. I have space vertical between my listview and your horizontalvariablelistview. Could you help me to do that please?

Add HListView left padding ?

Hello, thank you for your work. It looks very nice. My question is, can the left padding be changed? At the end of the list it's always a distance but on the left it starts from left with no padding or margin

HListView throws exception in Editor mode

When using HListView in the editor, it throws the following exception, preventing it from being previewed.

java.lang.IllegalStateException: Cannot find resource 'hlv_overscroll_edge'
at it.sephiroth.android.library.widget.EdgeEffect.(EdgeEffect.java:144)
at it.sephiroth.android.library.widget.AbsHListView.setOverScrollMode(AbsHListView.java:723)

Problem using HorizontalVariableListView as a header for a standard list view

I have successfully added the horizontal list view as a header to a standard list view. However, I am unable to get the horizontal view to register any click events.

I have implemented the OnItemClickedListener and OnItemSelectedListener as in the example so I guess the issue is related to it being a header view. Wehn inflating the header view and adding it I have tried to tried setting the isSelectable parameter to true and false both seem to have no effect.

           listView.addHeaderView(header, null, false);

I also call

                       listView.setItemsCanFocus(true);

after adding the header view

I have also tried adding

          android:descendantFocusability="afterDescendants"

To the header view to try and force the horizontal list view to get focus first. Any ideas?

A HorizontalVariableListView possible problem reusing views...

I'm using this control to show a list of ToggleButtons but only a ToggleButton can be active at a time. When the application starts everything is OK because none ToggleButton is pressed, but if I press any of them you can count 5 or 6 and the next ToggleButton in the list will be checked too, it is like a pattern, next 5 or 6 ToggleButton will be checked again.

Any ideas please.

Greetings

Empty mRecycleBin after fragment changes

I have HorizontalVariableListView in Fragment. Every item in adapter inflates different view.

  • I open the fragment. Fragment is added to backstack. HVLV is loaded. Visible items are loaded.

  • I switch to different fragment. OnDestroyView of the 1st fragment does removeAllViews();

  • I go back to 1st fragment. Its fetched with findFragmentByTag() from backstack. When it happens onCreate() is not invoked because fragment was not destroyed. in onCreateView() I have:

    if (view != null) {
        return view;
    }
    

    because I save the view of HVLV fragment in variable.

  • everything looks ok, but when I try scrolling HVLV I get errors:

Error in fillListRight:Invalid index 21, size is 0
in:

    try { 
            viewRecycled = mRecycleBin.get( viewType ).poll();
    } catch (Exception e) {
            Log.e(LOG_TAG, "Error in fillListRight:" + e.getMessage());
    }
    View child = mAdapter.getView( mRightViewIndex, viewRecycled, this );

or

removeNonVisibleItems() error:Invalid index 24, size is 0

    try {

        child = getChildAt( getChildCount() - 1 );
        while ( child != null && child.getLeft() - positionX >= mRightEdge ) {

            if ( null != mAdapter ) {
                int position = getPositionForView( child );
                int viewType = mAdapter.getItemViewType( position );
                mRecycleBin.get( viewType ).offer( child );
            }

            removeViewInLayout( child );
            mRightViewIndex--;
            child = getChildAt( getChildCount() - 1 );
        }
    } catch (Exception e) {
        Log.e(LOG_TAG, "removeNonVisibleItems() error:" + e.getMessage());
    }
  • there is something wrong with mRecycleBin

Btw the code works with this try and catch...

Lint issue: Android Studio layout view

screenshot 2014-02-07 17 16 56

Everything seems to work fine, but I get the following exception in the preview (Android 0.4.4)

        java.lang.IllegalStateException: Cannot find resource 'hlv_overscroll_edge'
            at it.sephiroth.android.library.widget.EdgeEffect.<init>(EdgeEffect.java:144)
            at it.sephiroth.android.library.widget.AbsHListView.setOverScrollMode(AbsHListView.java:723)
            at android.view.View.<init>(View.java:3449)
            at android.view.View.<init>(View.java:3505)
            at android.view.ViewGroup.<init>(ViewGroup.java:470)
            at it.sephiroth.android.library.widget.AdapterView.<init>(AdapterView.java:225)
            at it.sephiroth.android.library.widget.AbsHListView.<init>(AbsHListView.java:630)
            at it.sephiroth.android.library.widget.HListView.<init>(HListView.java:152)
            at it.sephiroth.android.library.widget.HListView.<init>(HListView.java:148)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
            at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:375)
            at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:100)
            at com.android.tools.idea.rendering.ProjectCallback.loadView(ProjectCallback.java:165)
            at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
            at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:135)
            at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:755)
            at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
            at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:758)
            at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
            at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:758)
            at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:373)
            at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:399)
            at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:336)
            at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:332)
            at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:548)
            at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:537)
            at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:929)
            at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:537)
            at com.android.tools.idea.rendering.RenderService.render(RenderService.java:609)
            at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:575)
            at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:81)
            at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$6$1.run(AndroidLayoutPreviewToolWindowManager.java:521)
            at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
            at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
            at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
            at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
            at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$6.run(AndroidLayoutPreviewToolWindowManager.java:516)
            at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
            at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
            at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
            at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
            at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
            at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
            at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
            at com.intellij.util.Alarm$Request$1.run(Alarm.java:297)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
            at java.util.concurrent.FutureTask.run(FutureTask.java:138)
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
            at java.lang.Thread.run(Thread.java:695)

Disapearing items, when scrolling HVLV

What should I do to use HorizontalVariableListView with BaseAdapter. I have class:

public class BrochuresHorizontalAdapter extends BaseAdapter{
private SparseArray items;
...
}
which stores list items in SparseArray. Unfortunately sometimes removed views by recycler are not recreated. getView is not invoked on low positions and items simply disappear. (--update: getView() is invoked)

Is it because I need some special things to make it work as Listview?

maybe question doesn't have sense, because BaseAdapter implements ListAdapter. But what could cause such behavior.

HorizontalListView in VerticalViewPager

Hi

I am using HorizontalListView in VerticalViewPager (https://github.com/castorflex/VerticalViewPager). I have multiple fragments in viewpager. When viewpager is created, fragment and horizontallistviews inside the fragment are created with no problems. But after scrolling to other fragments and come back to the fragment with horizontallistviews, horizontallistviews are removed from the screen. As i see, horizontallistviews are there but there is not cell, no items in it. I have also checked the adapter and item count. Nothing seems wrong. what might be the problem?

Thanks in advance.

smoothScrollTo... disregards duration, snaps to item

It appears that all of the smoothScrollTo methods simply snap to the given item, even ones with explicit duration arguments. Is this a known bug?

This is using version provided by Maven
compile 'it.sephiroth.android.library.horizontallistview:library:+'

Fatal Error

07-01 15:17:21.236: E/AndroidRuntime(1503): FATAL EXCEPTION: main
07-01 15:17:21.236: E/AndroidRuntime(1503): java.lang.NullPointerException
07-01 15:17:21.236: E/AndroidRuntime(1503): at de.meinprospekt.android.adapter.BrochuresHorizontalAdapter.getItem(BrochuresHorizontalAdapter.java:102)
07-01 15:17:21.236: E/AndroidRuntime(1503): at de.meinprospekt.android.adapter.BrochuresHorizontalAdapter.getView(BrochuresHorizontalAdapter.java:148)
07-01 15:17:21.236: E/AndroidRuntime(1503): at it.sephiroth.android.library.widget.HorizontalVariableListView.fillListRight(HorizontalVariableListView.java:827)
07-01 15:17:21.236: E/AndroidRuntime(1503): at it.sephiroth.android.library.widget.HorizontalVariableListView.fillList(HorizontalVariableListView.java:704)
07-01 15:17:21.236: E/AndroidRuntime(1503): at it.sephiroth.android.library.widget.HorizontalVariableListView.trackMotionScroll(HorizontalVariableListView.java:251)
07-01 15:17:21.236: E/AndroidRuntime(1503): at it.sephiroth.android.library.widget.IFlingRunnable.run(IFlingRunnable.java:78)
07-01 15:17:21.236: E/AndroidRuntime(1503): at android.os.Handler.handleCallback(Handler.java:587)
07-01 15:17:21.236: E/AndroidRuntime(1503): at android.os.Handler.dispatchMessage(Handler.java:92)
07-01 15:17:21.236: E/AndroidRuntime(1503): at android.os.Looper.loop(Looper.java:123)
07-01 15:17:21.236: E/AndroidRuntime(1503): at android.app.ActivityThread.main(ActivityThread.java:3701)
07-01 15:17:21.236: E/AndroidRuntime(1503): at java.lang.reflect.Method.invokeNative(Native Method)
07-01 15:17:21.236: E/AndroidRuntime(1503): at java.lang.reflect.Method.invoke(Method.java:507)
07-01 15:17:21.236: E/AndroidRuntime(1503): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
07-01 15:17:21.236: E/AndroidRuntime(1503): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
07-01 15:17:21.236: E/AndroidRuntime(1503): at dalvik.system.NativeStart.main(Native Method)

This error happened when application was resumed after not using phone for a moment.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.