Giter Site home page Giter Site logo

headerlistview's People

Contributors

elodieferrais avatar guilhermearaujo avatar nshtrifork avatar srayhunter avatar tokou 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

headerlistview's Issues

Can't use convertView in headers

The method

public View getRowView(int section, int row, View convertView, ViewGroup parent)

in the SectionAdapter class is always called with convertView and parent as null.

From HeaderListView.java line 262:

View header = mAdapter.getSectionHeaderView(actualSection, null, null);

This way, we cannot reuse inflated headers.

Also, since the parent is null, it is impossible to instantiate a LayoutInflater simply by calling LayoutInflater.from(parent.getContext()). One workaround for this is to pass a context when creating the adapter, and then getting the inflater from that context.

Dynamically add items instead of hard coded.

Be able to add items for array list or set individual strings. Example:

    ListView listview = (ListView) this.findViewById(R.id.listView1);
    NewAdapter adapter = new NewAdapter(this);
    // add("name","id");
    adapter.add("Section #1", "Section");
    adapter.add("Item #1", "Item");
    listview.setAdapter(adapter);

   // Adapter add() will see if it is a section or item and process it.
  add(String name, String id) {
  if(id.equals("Section") {
    // Set Section name and stuff
    // also set unclickable
  } else if (id.equals("Item") {
    // Set Item name and stuff
  }

Crash when returning to fragment as a tab. View with same id

This stackoverflow post has more details and the workaround: http://stackoverflow.com/questions/25807332/crash-when-returning-to-fragment-as-a-tab-view-with-same-id

With two tabs (A & B fragment using HeaderListView), when switching from B to A back to B, the app crashes with java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class android.widget.AbsListView$SavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/header_list_view. Make sure other views do not use the same id.

Other views are not using the same ID and to fix this issue I can listview.setId() in onCreateView to anything.

keep scroll position

thank for the lib first of all , i have a question is there anyway to keep scroll position after some new values added to the listview?

Visual Glitch when implementing HeaderListView in tabs/fragments

Hi,

I have created a tabView, each tab being a fragment containing the same HeaderListView.
Consider the following case:
Tab 0: Scroll down so that one "section" overlays on the screen
Swipe right
Tab 1: Do nothing
Swipe right
Tab 2: Do nothing
Swipe left
Tab 1: Do nothing
Swipe left
back to Tab 0.
The overlayed "section" will have disappeared (acting like a regular list would act). When starting scrolling, it will automatically reappear.

I found this behavior happening only when you have 3 or more Tabs. It seems that when you have 2 only, they are kept in memory, but when you have 3, only the direct neighbors will be kept in memory. Therefore, I think when the HeaderListView get regenerated, there is a visual glitch happening.

Thanks for this great library!

Scrollbar visible on launch

The full scrollbar is visible on application first launch. For example:

headerlistview

This is because the scrollbar is updated on updateScrollBar(), which is only called during onScroll(). This is a big issue when the number of rows don't fill the screen, so there is no need for scrolling and onScroll() is never called.

An easy fix (the way I did it) is to start with the scrollbar hidden (make mScrollView invisible during HeaderListView.init()

java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewGroup$LayoutParams android.view.View.getLayoutParams()' on a null object reference

App crashes, Reason: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewGroup$LayoutParams android.view.View.getLayoutParams()' on a null object reference

java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewGroup$LayoutParams android.view.View.getLayoutParams()' on a null object reference at com.example.libs.stickyheader.HeaderListView$HeaderListViewOnScrollListener.onScroll(HeaderListView.java:218) at android.widget.AbsListView.invokeOnItemScrollListener(AbsListView.java:1950) at android.widget.AbsListView.trackMotionScroll(AbsListView.java:7165) at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:6587) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777) at android.view.Choreographer.doCallbacks(Choreographer.java:590) at android.view.Choreographer.doFrame(Choreographer.java:559) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6891) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

Fast scroll

Is there a way to disable the fast scroll? In case of the fast scroll, HeaderListView crashes the application.

Any news on fast scroll implementation?

Thanks

Is there any option for making search?

I want to have a search box to find the value in the list. Is it possible?

I read the source code, HeaderListView class seems do no have this kind of option

java.lang.NoSuchMethodError in sample

Hello,

I just imported sample project in android studio to run on a GT-S5830 Android 2.3.3 (API10).
Sample Application crash when entering onStickyHeaderChanged method using setAlpha :

sample.TestActivity.onStickyHeaderChanged(TestActivity.java:203)

When removing this line for test, listView can scroll down, but can't scroll back to the top.

Can you fix this to get good practices for making a fully fonctional implementation ?
Many thx !

SectionAdapter.numberOfRows gets section == -1

When scrolling variable section==-1 is passed method numberOfRows.
Correct section numbers are also passed to this method, and it is not a big problem to check section in method body but this -1 is very unexpected.

Also, in Demo example we cannot watch such behavior cos` for every section (whatever it is) method returns 35, even for section -1

Headers incorrect when device rotated

If a list is partially scrolled and then the device rotated, the heading appears in the wrong place (e.g. half way down the screen). The header resets when scrolled to the top or past another heading.

How to change background color in RowView

Hi, firstly, congratulations for great work in the HeaderListView!!
My environment is ADT eclipse + java 7 + android 4.4.2. I'm using Navigation-drawer-page-sliding-tab-strip library and in the PageContentStripFragment class in onCreateView method I have:
HeaderListView list = new HeaderListView(getActivity(),null);
list.setAdapter(new ListViewSectionAdapter());
It's working!!
Hence, ListViewSectionAdapter is a subclass of SectionAdapter. In override getRowView method I inflated my layout called "custom_row_list".
So, i want to set custom background color when RowItem selected.
I did to set drawable selector and custom_row_list.xml:
android:background="@drawable/list_selector"

But not working!! What I doing wrong??

Thanks!

numberOfCellsBeforeSection has performance issue.

Hi Applidium,

The method numberOfCellsBeforeSection may have performance issue if the listview have lots sections. It is being called many times during scrolling. I am considering to extend the method and build a cache for it. When data set is changed, wipe the cache.

Simon

Populating header and row dynamically

Hello how can i inject the items below inside SectionAdapter ?

    List<Item> items = new ArrayList<Item>();
    items.add(new Header("Header 1"));
    items.add(new ListItem("Text 1", "Rabble rabble"));
    items.add(new ListItem("Text 2", "Rabble rabble"));
    items.add(new ListItem("Text 3", "Rabble rabble"));
    items.add(new ListItem("Text 4", "Rabble rabble"));

    items.add(new Header("Header 2"));
    items.add(new ListItem("Text 5", "Rabble rabble"));
    items.add(new ListItem("Text 6", "Rabble rabble"));
    items.add(new ListItem("Text 7", "Rabble rabble"));
    items.add(new ListItem("Text 8", "Rabble rabble"));
    items.add(new ListItem("Text 9", "Rabble rabble"));
    items.add(new ListItem("Text 10", "Rabble rabble"));

Programmatically scroll to section header

Is there any way to programmatically scroll to a particular section header? I have buttons along the top of my ListView which represent the different section headers, and I want to scroll to the appropriate section upon tapping them. Is this possible?

Could not find class

I have added the project in my workspace and added the project to the build path, but I still get the "could not find class com.applidium.headerlistview.HeaderlistView. I am not sure what else needs to be done, although I am able to run the DEMO.

Adding Custom OnScrollListener forcing the section header scrolling

Hi,

I have added my custom OnScrollListener which is AbsListView.OnScrolllistener on HeaderListView ,because its own onscrolllistener is required for minimum Api LEVEL 23(my minimum is 15).
It is forcing the section headers scrolling.I want to fix the sectional headrers.Kindly give me some advice.

Below is my custom implementation:-
MyClass implements AbsListView.OnScrollListener
{
@Bind(R.id.receipt_list)
HeaderListView mReceiptsList;

    mReceiptsList.getListView().setOnScrollListener(this);

@OverRide
public void onScrollStateChanged(AbsListView view, int scrollState) {
this.currentScrollState = scrollState;
this.isScrollCompleted();//the method to detect scroll completion
}

@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    this.currentFirstVisibleItem = firstVisibleItem;
    this.currentVisibleItemCount = visibleItemCount;
    this.totalItemCount = totalItemCount;
}

   /***By this methos I detect if there's been a scroll which has completed***/
private void isScrollCompleted() {
    if (this.currentVisibleItemCount > 0 && this.currentScrollState == SCROLL_STATE_IDLE && this.totalItemCount == (currentFirstVisibleItem + currentVisibleItemCount)) {
 
        if(canLoad) { //class variables to manipulate the data
            pageNumber =pageNumber +1;
            refreshScreen();
        }
    }
}

}

Demo crashing - patched

I just put in a patch for this issue in the Demo. There was a problem where views would be recycled, but they were for the wrong type of view. The issue caused a null reference to be returned for R.id.text2when recycling a convertView that had originally been a TextView.

First header issue

Hi there!
I am encountering an issue using your library.
As you can see in the following screenshots only the first header "additional toppings" scrolls as like as the children. After scrolling it a bit it gets repositioned in the correct way (sticky at the top).
Do you have any idea how to fix it?

I'm using the listview inside a custom dialog.
header scrolling
header after scrolling

Is it possible to stop the scrolling?

I tried setEnabled(False) and also setClickable(False) but they don't work.
The thing is I need to stop the list from being scrollable when I press on a list item.

Section with dynamic rows

Hello, i am working on an app. I want to display the rows with dynamic size.
But, as your function
@OverRide
public int numberOfRows(int section)
{
34;
}

Which creates 35 rows in each section.
I want 2 rows in first section, 5 rows in second section.. like wise..
How can i achieve this?
Thanks in advance..!! :)

documentation

You should add to the documentation that we should always override getSectionHeaderViewTypeCount

because I only have 1 type of header so I tought I didn't need it... and have been debugging for some hours...

everything else rocks! thanks :D

No highlight/ripple

There is no highlight or ripple effect when an item in the row is click.
A normal listview would have a highlight or a ripple effect (> L) when they are clicked.

Divider between header and row

I'm using header and one row in section. Header contains title and the row contains image. I've noticed gray line , that looks like a divider, above image view which is located in row since it goes under the header as the row is scrolled. Any idea how to remove this?

HeaderListViewOnScrollListener.updateScrollBar

I have imported your project and created a new project using the library given. It works fine till the values are static i have the setContentView() set as HeaderListview id. But when i change the from listview to HeaderListview in xml file it gives me the following error.
" java.lang.ArithmeticException: / by zero at com.applidium.headerlistview.HeaderListView$HeaderListViewOnScrollListener.updateScrollBar(HeaderListView.java:215) at com.applidium.headerlistview.HeaderListView$HeaderListViewOnScrollListener.onScroll(HeaderListView.java:115) "

Please help me in solving this error.
I need to setContentView() a different layout as i have other elements also on the same xml file.

First section without any row items

Thanks for the Fix #9 Tokou. Unfortunately I am still experiencing some issues if the FIRST section has no rows. In this case the second section header is displayed twice as soon as I scroll down the list. From what I understand, this behaviour does not occur if I disable the changes from Fix #21 .

[Question] Best way to refresh listview?

Hey there.

I'm loading in data dynamically like so..

 ParseQuery<Assignment> query = ParseQuery.getQuery(Assignment.class);
    query.whereEqualTo("owner", ParseUser.getCurrentUser());
    query.fromLocalDatastore();
    query.findInBackground(new FindCallback<Assignment>() {
        @Override
        public void done(List<Assignment> results, ParseException e) {
            finishedList = new ArrayList<Assignment>();
            unfinishedList = new ArrayList<Assignment>();
            completed=0;
            uncomplete=0;
            for(Assignment a: results){
                Log.d("Assignment", a.getName());
                if(a.getComplete()){
                    finishedList.add(a);
                    completed++;
                }
                else{
                    unfinishedList.add(a);
                    uncomplete++;
                }
            }
            notifyDataSetChanged();
            //if(mListener!=null)setListAdapter(new ArrayAdapter<Assignment>(getActivity(),
            //       android.R.layout.simple_list_item_1, android.R.id.text1, results));
        }
     });

The problem is that the app crashes at notifyDataSetChanged();

I have attached the entire file other then the actual row rendering. If i remove notifydatasetchanged it will work but will not show the rows which defeats the point.

package com.michaellatman.studybranch.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.applidium.headerlistview.SectionAdapter;
import com.michaellatman.studybranch.R;
import com.michaellatman.studybranch.objects.Assignment;
import com.parse.FindCallback;
import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseUser;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * Created by michael on 8/10/14.
 */
public class AssignmentAdapter extends SectionAdapter {
    int completed = 0;
    int uncomplete = 0;

    List<Assignment> finishedList = null;
    List<Assignment> unfinishedList = null;
    Context ctx = null;
    public AssignmentAdapter(Context ctx){
        this.ctx = ctx;
        ParseQuery<Assignment> query = ParseQuery.getQuery(Assignment.class);
        query.whereEqualTo("owner", ParseUser.getCurrentUser());
        query.fromLocalDatastore();
        query.findInBackground(new FindCallback<Assignment>() {
            @Override
            public void done(List<Assignment> results, ParseException e) {
                finishedList = new ArrayList<Assignment>();
                unfinishedList = new ArrayList<Assignment>();
                completed=0;
                uncomplete=0;
                for(Assignment a: results){
                    Log.d("Assignment", a.getName());
                    if(a.getComplete()){
                        finishedList.add(a);
                        completed++;
                    }
                    else{
                        unfinishedList.add(a);
                        uncomplete++;
                    }
                }
                notifyDataSetChanged();
                //if(mListener!=null)setListAdapter(new ArrayAdapter<Assignment>(getActivity(),
                //       android.R.layout.simple_list_item_1, android.R.id.text1, results));
            }
        });
    }
    @Override
    public boolean hasSectionHeaderView(int section) {
        return true;
    }
    @Override
    public int getSectionHeaderViewTypeCount() {
        return 1;
    }

    @Override
    public int getSectionHeaderItemViewType(int section) {
        return 1;
    }

    @Override
    public View getSectionHeaderView(int section, View convertView, ViewGroup parent) {


        if (convertView == null) {
            LayoutInflater vi = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = vi.inflate(R.layout.item_header, null);
        }

            //((TextView) convertView).setText("Header for section " + section);


        return convertView;
    }

    @Override
    public int numberOfSections() {
        return 2;
    }

    @Override
    public int numberOfRows(int section) {
        Log.d("NumRows",""+section+" "+uncomplete+" "+completed);
        switch (section){
            case 0:
                return uncomplete;
            case 1:
                return completed;
        }
        return section;
    }

    @Override
    public View getRowView(int section, int row, View convertView, ViewGroup parent) {
        View v = convertView;

        if (convertView == null) {
            LayoutInflater vi = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.item_assignment, null);
        }

       ......
       return v;
    }

    @Override
    public Object getRowItem(int section, int row) {
        Log.d("Get","row");
        switch (section){
            case 0:
                return unfinishedList.get(row);
            case 1:
                return finishedList.get(row);
        }
        return null;
    }
}

onRowItemClick(...) not called

Thanks for your fantastic work, I do enjoy working with HeaderListView a lot. Nevertheless I have one problem related to click events.

I implemented the onRowItemClick(...) method in my Section Adapter. Unfortunately it is not called and I don't know why. Do I need to "attach" it to the HeaderListView?

Please let me know if you need further information.

It would be very helpful if you would include an example for this in the HeaderListViewDemo.

Thank you & best regards,
Sebastian

how to use HeaderListView with a CalendarPickerView

Hello,
I need to use HeaderListView with a CalendarPickerView to have a stickyscroll for the headers of my calender(months).
This is what I did :
I changed the inheritence of CalendarPickerView class from ListView to HeaderListView (changed all the methods to keep it working). Then, I created my CalendarAdapter class that extends from SectionAdapter class (but I didn't implements the abstract methods ).

I don't know what I have to do after that ! Thanks !

Sections without any row items

I am currently using the HeaderListView to display data where some sections might have no row items (the section header is and should be shown regardless of this fact). Now, when I scroll down through the HeaderListView I am experiencing a weird bug for those section headers without any rows. As soon as they begin to exit the visible area, it is overridden by a previously shown section header view.

I can provide some screenshots to clarify the issue if wanted.

Switching Header Label values

I'm showing a ListView with 3 sort buttons above it (Name, Country, Age). When sorting changes, I'm updating the HeaderListview like this:
((PeopleSectionedAdapter) listView.getAdapter()).setLinkedPeopleMap(indicesBR.get("name"));
((PeopleSectionedAdapter) listView.getAdapter()).notifyDataSetChanged();
or
((PeopleSectionedAdapter) listView.getAdapter()).setLinkedPeopleMap(indicesBR.get("country"));
((PeopleSectionedAdapter) listView.getAdapter()).notifyDataSetChanged();
or
((PeopleSectionedAdapter) listView.getAdapter()).setLinkedPeopleMap(indicesBR.get("age"));
((PeopleSectionedAdapter) listView.getAdapter()).notifyDataSetChanged();

Actually it works, but when I havent scrolled below the 2nd Header, the currently active header doesn't get changed at all. E.g. I have selected "Name" and I scrolled down just a very small amount - then the currently active header still says "A", while the next visible header displays the correct title. I'd have to scroll down until the next header gets active and then scroll back to update the previously active one. This problem doesn't occur if I don't do any scrolling at all.
How can I fix this?

No marked region found along edge. - Found along top edge.

drawable-hdpi/scrollbar_handle_holo_dark.9.png errors in Android Studio 0.4.2 with

Error: Failed to run command: build-tools/17.0.0/aapt s -i /drawable-hdpi/scrollbar_handle_holo_dark.9.png -o /debug/drawable-hdpi/scrollbar_handle_holo_dark.9.png
Error Code:
42
Output:
ERROR: 9-patch image drawable-hdpi/scrollbar_handle_holo_dark.9.png malformed.
No marked region found along edge.
Found along top edge.

I've removed paths for brevity, deleting dark.9 and replacing with light.9 renamed does not solve the problem.

Having used /Applications/Android\ Studio.app/sdk/tools/draw9patch to add the lines it works but not sure I added them in the right please

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.