-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working on separate page to view recipes
- Loading branch information
1 parent
ee6bb97
commit f7709c9
Showing
4 changed files
with
94 additions
and
5 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
app/src/main/java/com/example/cmsc355cookbookapp/RecipeRVAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.example.cmsc355cookbookapp; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class RecipeRVAdapter extends RecyclerView.Adapter<RecipeRVAdapter.ViewHolder> { | ||
|
||
// variable for our array list and context | ||
private ArrayList<recipes_class> recipes_classArrayList; | ||
private Context context; | ||
|
||
// constructor | ||
public RecipeRVAdapter(ArrayList<recipes_class> recipes_classArrayList, Context context) { | ||
this.recipes_classArrayList = recipes_classArrayList; | ||
this.context = context; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | ||
// on below line we are inflating our layout | ||
// file for our recycler view items. | ||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recipe_rv_item, parent, false); | ||
return new ViewHolder(view); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) { | ||
// on below line we are setting data | ||
// to our views of recycler view item. | ||
recipes_class modal = recipes_classArrayList.get(position); | ||
holder.recipeTV.setText(modal.getRecipe()); | ||
holder.ing1TV.setText(modal.getR_ing1()); | ||
holder.ing2TV.setText(modal.getR_ing2()); | ||
holder.ing3TV.setText(modal.getR_ing2()); | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
// returning the size of our array list | ||
return recipes_classArrayList.size(); | ||
} | ||
|
||
public class ViewHolder extends RecyclerView.ViewHolder { | ||
|
||
// creating variables for our text views. | ||
private TextView recipeTV, ing1TV, ing2TV, ing3TV; | ||
|
||
public ViewHolder(@NonNull View itemView) { | ||
super(itemView); | ||
// initializing our text views | ||
recipeTV = itemView.findViewById(R.id.et_recipe); | ||
ing1TV = itemView.findViewById(R.id.et_ing1); | ||
ing2TV = itemView.findViewById(R.id.et_ing2); | ||
ing3TV = itemView.findViewById(R.id.et_ing3); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
<RelativeLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".ViewRecipes"> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
<!--recycler view for displaying our courses--> | ||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/idRVCourses" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> | ||
|
||
|
||
</RelativeLayout> |