Android Recycler view Horizontal and vertical Orientation Scroll Controll

mLayoutManager = new LinearLayoutManager(convertView.getContext(),LinearLayoutManager.HORIZONTAL,false);

Complete Example :


import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.dsb.deshipos.Adapter.CatergoryAdapter;
import com.dsb.deshipos.Library.HandlingServer;
import com.dsb.deshipos.Model.Category;
import com.dsb.deshipos.R;

import java.util.ArrayList;

/**
* Created by dynamicsolversbangladesh1 on 3/31/16.
*/
public class ItemListFragment extends Fragment {
private RecyclerView mRecyclerView;
private RecyclerView.Adapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;

ArrayList categoryArrayList;

HandlingServer handlingServer;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View convertView = inflater.inflate(R.layout.itemslistfragmentlayout, container, false);

mRecyclerView = (RecyclerView) convertView.findViewById(R.id.item_recycler);

// use this setting to improve performance if you know that changes
// in content do not change the layout size of the RecyclerView
mRecyclerView.setHasFixedSize(true);

// use a linear layout manager
mLayoutManager = new LinearLayoutManager(convertView.getContext(),LinearLayoutManager.HORIZONTAL,false);
mRecyclerView.setLayoutManager(mLayoutManager);

handlingServer=new HandlingServer(convertView.getContext());
categoryArrayList=handlingServer.getAllCategories();

// specify an adapter (see also next example)
mAdapter = new CatergoryAdapter(convertView.getContext(),categoryArrayList);
mRecyclerView.setAdapter(mAdapter);
return convertView;
}
}

মন্তব্য করুন

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  পরিবর্তন )

Google photo

You are commenting using your Google account. Log Out /  পরিবর্তন )

Twitter picture

You are commenting using your Twitter account. Log Out /  পরিবর্তন )

Facebook photo

You are commenting using your Facebook account. Log Out /  পরিবর্তন )

Connecting to %s