简体   繁体   English

如何在android中的Listview中从右向左分配水平滚动

[英]How to assign horizontal scroll right to left in Listview in android

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. 我搜索这个我发现了一些smoothscrollto =“20dp”,但它根本不会工作。

Edited text I Added holder.hv.smoothScrollTo(holder.hv.getRight(), holder.hv.getTop()); 编辑文本我添加了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;
}

any help is appreciated. 任何帮助表示赞赏。 Thank you 谢谢

Please use this link Screenshot from My NEXUS 7 : 请使用此链接 My NEXUS 7的屏幕截图: 在此输入图像描述

I solve this question with the help of @Appu and other member of stack overflow... 我在@Appu和堆栈溢出的其他成员的帮助下解决了这个问题...

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 is horizontalscrollview // Hv是horizo​​ntalscrollview

                     }
                  });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM