Commit e5419a99 authored by austin.blanke's avatar austin.blanke

Working Recycler View

parent 97555dfb
...@@ -16,23 +16,25 @@ import java.util.ArrayList; ...@@ -16,23 +16,25 @@ import java.util.ArrayList;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
adapter adapterObj;
ArrayList<String> dataList;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
Bundle loginBundle = getIntent().getExtras(); dataList = new ArrayList<>();
String currentUser = loginBundle.getString("currentUser"); dataList.add("Test1");
dataList.add("Test2");
TextView username = (TextView) findViewById(R.id.Username); dataList.add("Test3");
username.setText(currentUser); dataList.add("Test4");
dataList.add("Test5");
performanceList = new ArrayList<>(); RecyclerView recyclerObj = findViewById(R.id.performances);
RecyclerView recyclerObj = findViewById(R.id.performanceRecycler);
recyclerObj.setLayoutManager(new LinearLayoutManager(this)); recyclerObj.setLayoutManager(new LinearLayoutManager(this));
adapter = new performanceRecAdapter(this, performanceList); adapterObj = new adapter(this, dataList);
recyclerObj.setAdapter(adapter); recyclerObj.setAdapter(adapterObj);
} }
} }
\ No newline at end of file
package com.example.bookingapp_austinblanke;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
public class MyAdapter extends RecyclerView.Adapter<MyViewHolder> {
private Context context;
private ArrayList name_id;
public MyAdapter(Context context, ArrayList name_id) {
this.context = context;
this.name_id = name_id;
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(context).inflate(R.layout.performance,parent,false);
return new MyViewHolder(v);
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
}
@Override
public int getItemCount() {
return 0;
}
}
package com.example.bookingapp_austinblanke;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
public class MyViewHolder extends RecyclerView.ViewHolder{
TextView name;
public MyViewHolder(@NonNull View itemView) {
super(itemView);
}
}
package com.example.bookingapp_austinblanke;
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.List;
public class adapter extends RecyclerView.Adapter<adapter.ViewHolder>{
private List<String> mData;
private LayoutInflater mInflater;
adapter(Context context, List<String> data){
this.mInflater = LayoutInflater.from(context);
this.mData = data;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType){
View view = mInflater.inflate(R.layout.performance, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
String name = mData.get(position);
holder.myTextView.setText(name);
}
@Override
public int getItemCount() {
return mData.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
TextView myTextView;
ViewHolder(View v){
super(v);
myTextView = itemView.findViewById(R.id.performance);
}
}
}
...@@ -7,17 +7,13 @@ ...@@ -7,17 +7,13 @@
android:background="#F2F1E8" android:background="#F2F1E8"
tools:context=".MainActivity"> tools:context=".MainActivity">
<TextView
android:id="@+id/textView" <androidx.recyclerview.widget.RecyclerView
android:layout_width="wrap_content" android:id="@+id/performances"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:background="#00050533" android:layout_height="match_parent"
android:text="Shows"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintVertical_bias="0.199" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cardElevation="12dp"
android:cardCornerRadius="16dp"
android:layout_margin="16dp"
android:backgroundTint="#efefef">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
androidtext="Performance"
android
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="5dp"
android:layout_marginTop="5dp"
android:orientation="vertical">
<TextView
android:id="@+id/performance"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_alignWithParentIfMissing="true"
android:gravity="center_vertical"
android:text="Line 1"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:textSize="18sp"/>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#CCCCCC"
/>
</LinearLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment