Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.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
使用TwoWayView在android中查看HorizontalView时更改imageButton状态_Android_Horizontal Scrolling_Onscroll - Fatal编程技术网

使用TwoWayView在android中查看HorizontalView时更改imageButton状态

使用TwoWayView在android中查看HorizontalView时更改imageButton状态,android,horizontal-scrolling,onscroll,Android,Horizontal Scrolling,Onscroll,注意:任何人都不知道该怎么做??? TwoWayView Library可在水平方向上显示图像。单击“图像”按钮,可显示所有图像 成功地 我的问题: 当我使用TwoWayView调用horizontalview时,只需更改imagebutton背景 (like when load ui then imagebutton background will be display colored and onscolling time then all imagebutton background w

注意:任何人都不知道该怎么做???

TwoWayView Library可在水平方向上显示图像。单击“图像”按钮,可显示所有图像 成功地

我的问题:

当我使用TwoWayView调用horizontalview时,只需更改imagebutton背景

(like when load 
ui then imagebutton background will be display colored and onscolling time then all
imagebutton background will be grayscale and after stop scolling then again imagebutton
background will be initail phase ie colored)
有一秒钟

这里,另一个问题是如何使用GPUImage进行灰度更改并恢复为彩色。 我在IOS上成功转换,但无法使用此android

我试图使用编程设置的imagebutton状态,因为我没有;我不知道图像 因为它来自服务器

    StateListDrawable stateList = new StateListDrawable();
    stateList.addState(new int[] { android.R.attr.state_focused}, dataImage.get(1));
    stateList.addState(new int[] {},  dataImage.get(0));
    holder.imageButton.setBackgroundDrawable(stateList);
使用自定义适配器,下面是完整代码:

现在,回到MainActivity,我所做的:

完整代码-主活动: 我已经声明了双向视图和实现

String stateName;
      mListView = new TwoWayView(getApplicationContext());
        mListView.setItemMargin(10);
        mListView.setLongClickable(true);
        mListView.setOrientation(Orientation.HORIZONTAL);


        mListView.setHorizontalScrollBarEnabled(true);
        mListView.setVerticalScrollBarEnabled(false);

         mListView.setOnScrollListener(new TwoWayView.OnScrollListener() {
            private boolean scrolling=false;

            @Override
            public void onScrollStateChanged(TwoWayView view, int scrollState) {
                stateName = "Undefined";
                switch(scrollState) {
                case SCROLL_STATE_IDLE:
                    stateName = "Idle";
                    break;

                case SCROLL_STATE_TOUCH_SCROLL:
                    stateName = "Dragging";
                    break;

                case SCROLL_STATE_FLING:
                    stateName = "Flinging";
                    break;
                }


            }

            @Override
            public void onScroll(final TwoWayView view, int firstVisibleItem,
                    int visibleItemCount, int totalItemCount) {
                int childcount = view.getChildCount();
                Log.e("STATE", "state Name="+stateName);
                if (stateName.equalsIgnoreCase("Flinging")) {
                     for (int i=0; i < childcount; i++){
                         view.getChildAt(i).setSelected(true);
                     }
                }else if (stateName.equalsIgnoreCase("Idle")) {
                 for (int i=0; i < childcount; i++){
                     view.getChildAt(i).setSelected(false);
                    }
                }else {
                    for (int i=0; i < childcount; i++){
                     view.getChildAt(i).setSelected(false);
                    }
                }

            }
        });
字符串stateName;
mListView=新的双向视图(getApplicationContext());
mListView.setItemMargin(10);
mListView.setLongClickable(true);
mListView.setOrientation(方向.水平);
mListView.setHorizontalScrollBarEnabled(true);
mListView.setVerticalScrollBarEnabled(false);
mListView.setOnScrollListener(新的TwoWayView.OnScrollListener(){
私有布尔滚动=false;
@凌驾
CrollStateChanged上的公共无效(双向视图视图,int-scrollState){
stateName=“未定义”;
开关(滚动状态){
案例滚动\u状态\u空闲:
stateName=“空闲”;
打破
案例滚动\状态\触摸\滚动:
stateName=“拖动”;
打破
案例滚动\u状态\u抛出:
stateName=“投掷”;
打破
}
}
@凌驾
public void onScroll(最终双向视图,int firstVisibleItem,
int visibleItemCount,int totalItemCount){
int childcount=view.getChildCount();
Log.e(“STATE”、“STATE Name=“+stateName”);
if(stateName.equalsIgnoreCase(“甩”)){
for(int i=0;i
我的意图是更改图像颜色,但这里我的示例只是更改图像dataImage.get(0)处于初始和edle状态 和数据图像。在投掷状态下获取(1)图像背景

输出:当侧扫右侧图像消失,从右向左时,则没有任何效果