如何分配在列表视图,以留在android的水平滚动的权利 [英] How to assign horizontal scroll right to left in Listview in android

查看:162
本文介绍了如何分配在列表视图,以留在android的水平滚动的权利的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经装箱的列表视图行嵌套的视图。还我已经使用水平滚动以便在特定行水平滚动。
但在一些数字行我想从右到左有滚动设施。
我搜索一下这方面,我发现了一些smoothscrollto =20dp,但它不会在所有的工作。

i have crated nested view for list view row . also i have used horizontal scroll view to scroll horizontally in particular row. but in some number of row i want to have scrolling facility from right to left. i search about this i found something smoothscrollto="20dp" but it wont work at all.

编辑的文本
我加了 holder.hv.smoothScrollTo(holder.hv.getRight(),holder.hv.getTop()); 在点击监听我的图像的视图,当我点击上图像查看我的水平滚动视图转移到结尾(右)..
我怎样才能使人们有可能滚动该特定行没有点击监听器
这里是我的code

Edited text I Added holder.hv.smoothScrollTo(holder.hv.getRight(), holder.hv.getTop()); in my image-view on click listener and when i click on that image-view my horizontal scroll view shift to end(right).. how can i make it possible to scroll that particular row without click listener Here is my code

 public View getView(int position, View convertView, ViewGroup parent) {
    final ViewHolder holder;
    int type = getItemViewType(position);
    System.out.println("getView " + position + " " + convertView + " type = " + type);
    if (convertView == null) {
        holder = new ViewHolder();
        switch (type) {
            case 0:
                convertView = inflater.inflate(R.layout.list_row1, null);
                 holder.hv = (HorizontalScrollView)convertView.findViewById(R.id.horizontalScrollView1);
                holder.videoview1 = ((ImageView)convertView.findViewById(R.id.train).findViewById(R.id.boogi1).findViewById(R.id.imageView1));
                Log.d("Listview", "front value is"+position);
                holder.videoview1.setTag(position);
                holder.videoview1.setOnClickListener(new OnClickListener() {                
                    @Override
                    public void onClick(View v) {
                        // TODO Auto-generated method stub

                        holder.hv.smoothScrollTo(holder.hv.getRight(), holder.hv.getTop());
                        }
                });


                break;
            case 1:convertView = inflater.inflate(R.layout.list_row2, null);
                holder.videoview1 = ((ImageView)convertView.findViewById(R.id.train2).findViewById(R.id.boogi2).findViewById(R.id.imageView1)); 
                holder.videoview1.setTag(position);
                holder.videoview1.setOnClickListener(new OnClickListener() {                
                    @Override
                    public void onClick(View v) {
                        // TODO Auto-generated method stub
                        Toast.makeText(context, "you right clicked"+v.getTag() , Toast.LENGTH_SHORT).show();                        
                    }
                });
                break;
        }
        convertView.setTag(holder);
    } else {

        holder = (ViewHolder)convertView.getTag();

    }

    return convertView;
}

任何帮助是AP preciated。
谢谢

any help is appreciated. Thank you

推荐答案

我解决@Appu的帮助和堆栈溢出的其他成员这个问题...

I solve this question with the help of @Appu and other member of stack overflow...

我刚刚加入这个code到我想要滚动到右自动行

Just i added this code into the row which i want to scroll to right automatically

holder.hv.post(new Runnable() 
                {
                    public void run() 
                     {
   holder.hv.smoothScrollTo(holder.hv.getRight()+80, holder.hv.getTop());

// HV是horizo​​ntalscrollview

// Hv is horizontalscrollview

                     }
                  });

这篇关于如何分配在列表视图,以留在android的水平滚动的权利的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆