Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android:FastScrolling SectionIndexer getSections()只调用一次_Java_Android_Listview_Scroll - Fatal编程技术网

Java Android:FastScrolling SectionIndexer getSections()只调用一次

Java Android:FastScrolling SectionIndexer getSections()只调用一次,java,android,listview,scroll,Java,Android,Listview,Scroll,我已经创建了一个列表视图,它正在使用快速滚动。(参见图)当用户单击下面的任何按钮(即所有曲目、艺术家、专辑)时,每次调用以下自定义ArrayDater时 ArrayAdapter<String> adapter = new ScrollIndexListAdapter(Listing.this, elements); //Code for ScrollIndexListAdapter is below 最新的FastScroll版本似乎没有这个问题。但是,在你的情况下,有一个转折

我已经创建了一个
列表视图
,它正在使用
快速滚动
。(参见图)当用户单击下面的任何按钮(即所有曲目、艺术家、专辑)时,每次调用以下自定义ArrayDater时

ArrayAdapter<String> adapter = new ScrollIndexListAdapter(Listing.this, elements); 
//Code for ScrollIndexListAdapter is below

最新的FastScroll版本似乎没有这个问题。但是,在你的情况下,有一个转折点。将适配器设置为ListView时,禁用并启用快速滚动。请参阅下面的代码:

            adapter = new ScrollIndexListAdapter(this, data);
            listView.setFastScrollEnabled(false);
            listView.setAdapter(adapter);
            listView.setFastScrollEnabled(true);

我在Android上的经验是有限的,但我认为应该通过在适配器中调用
notifyDataSetChanged()
来广播对底层数据源的更改。
            adapter = new ScrollIndexListAdapter(this, data);
            listView.setFastScrollEnabled(false);
            listView.setAdapter(adapter);
            listView.setFastScrollEnabled(true);