Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<HomeAvailability> homeData = new ArrayList<>();
- homeData.add(new HomeAvailability("1111 Main St", "Jun"));
- homeData.add(new HomeAvailability("1111 Main St", "Jul"));
- homeData.add(new HomeAvailability("1111 Main St", "Aug"));
- homeData.add(new HomeAvailability("1111 Park St", "Jul"));
- homeData.add(new HomeAvailability("2222 Park St", "Aug"));
- homeData.add(new HomeAvailability("2222 Oregon St", "Oct"));
- homeData.add(new HomeAvailability("1111 Oregon St", "Nov"));
- homeData.add(new HomeAvailability("1111 Oregon St", "Dec"));
- homeData.add(new HomeAvailability("1111 Oregon St", "Jan"));
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
- mLayoutManager = new LinearLayoutManager(this);
- mRecyclerView.setLayoutManager(mLayoutManager);
- MainAdapter mAdapter = new MainAdapter(homeData);
- mRecyclerView.setAdapter(mAdapter);
- }
- public class CustomAdapter extends RecyclerView.Adapter<CustomAdapter.ViewHolder> {
- public static class ViewHolder extends RecyclerView.ViewHolder {
- CardView cv;
- TextView address;
- TextView month;
- public ViewHolder(View itemView) {
- super(itemView);
- cv = (CardView)itemView.findViewById(R.id.card_view);
- address = (TextView)itemView.findViewById(R.id.address);
- month = (TextView)itemView.findViewById(R.id.month);
- }
- }
- public CustomAdapter(List<HouseAvailability> myDataset) {
- this.mDataset = myDataset;
- }
- @Override
- public void onAttachedToRecyclerView(RecyclerView recyclerView) {
- super.onAttachedToRecyclerView(recyclerView);
- }
- @Override
- public CustomAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup,
- int viewType) {
- View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.card_layout, viewGroup, false);
- ViewHolder vh = new ViewHolder(v);
- return vh;
- }
- @Override
- public void onBindViewHolder(ViewHolder holder, int position) {
- holder.address.setText(mDataset.get(position).adress);
- }
- @Override
- public int getItemCount() {
- return mDataset.size();
- }
- <android.support.v7.widget.CardView
- xmlns:card_view="http://schemas.android.com/apk/res-auto"
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/card_view"
- android:layout_gravity="center"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- card_view:cardCornerRadius="6dp">
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <TextView
- android:id="@+id/address"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:maxLines="3"
- android:padding="16dp"
- android:textColor="#222"
- android:textStyle="bold"
- android:textSize="20sp" />
- <View
- android:id="@+id/divider"
- android:layout_below="@id/address"
- android:layout_width="match_parent"
- android:layout_height="1dp"
- android:layout_margin="4dp"
- android:background="@android:color/black" />
- //Months here?
- </RelativeLayout>
- </RelativeLayout>
- </android.support.v7.widget.CardView>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement