implement HorizontalScrollView inside ListView

徘徊边缘 提交于 2019-12-07 19:46:38

问题


I implement successful HorizontalScrollView using this sample code and this . which will fetch the data from a server

but now I'm trying to make a horizontal scroll view inside a ListView , i not find the right way!!! So that each element of list Will contain this :

> RelativeLayout(vertical)
  > RelativeLayout
    > ImageView
    > TextView
  > HorizontalScrollView 
    > LinearLayout (horizontal)

MainActivity

        actorsList = new ArrayList<Actors>();

        new JSONAsyncTask().execute("http://microblogging.wingnity.com/JSONParsingTutorial/jsonActors");    

centerLockHorizontalScrollview = (CenterLockHorizontalScrollview) findViewById(R.id.scrollView);        
            adapter = new ActorAdapter(getApplicationContext(), R.layout.row, actorsList);      
            centerLockHorizontalScrollview.setAdapter(MainActivity.this, adapter); 

listview.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"    android:background="#F1F1F1"
    >

    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

    </ListView>

</LinearLayout> 

code of my getView method in adapter class

@Override
    public View getView(final int position, View convertView, ViewGroup parent) {

        View v = convertView;
        if (v == null) {
            holder = new ViewHolder();
            v = vi.inflate(Resource, null);
            holder.imageview = (ImageView) v.findViewById(R.id.ivImage);
            holder.tvName = (TextView) v.findViewById(R.id.tvName);
             //     //    //     //    //     ///
        } else {
            holder = (ViewHolder) v.getTag();
        }
        holder.imageview.setImageResource(R.drawable.ic_launcher);
        new DownloadImageTask(holder.imageview).execute(actorList.get(position).getImage());
        holder.tvName.setText(actorList.get(position).getName());

       //     //     //     //    //     ///

        v.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                Log.i("mh", ""+actorList.get(position).getName());

            }
        });
        return v;

    }

    static class ViewHolder {
        public ImageView imageview;
        public TextView tvName;
          //     //       //

    }

来源:https://stackoverflow.com/questions/28783628/implement-horizontalscrollview-inside-listview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!