implement HorizontalScrollView inside ListView

2019-05-20 19:10发布

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;
          //     //       //

    }

0条回答
登录 后发表回答