Commit d216ed85 authored by lucy.hemingway's avatar lucy.hemingway

third commit with museum list beginning

parent c7d1892e
......@@ -33,6 +33,9 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.android.support:recyclerview-v7:28.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
......
......@@ -9,7 +9,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.APPPPPpp">
<activity android:name=".HelpPage"></activity>
<activity android:name=".MuseumList"></activity>
<activity android:name=".HelpPage" />
<activity android:name=".Register" />
<activity android:name=".LogIn" />
<activity android:name=".MainMenu">
......
package com.example.appppppp;
import android.content.Context;
import android.content.Intent;
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;
import java.util.List;
class adapter extends RecyclerView.Adapter<adapter.ViewHolder> {
private List<MuseumNames> myMuseums;
private LayoutInflater myInflater;
// pass the data list into the constructor
adapter(Context context, ArrayList<MuseumNames> data){
this.myInflater = LayoutInflater.from(context);
this.myMuseums = data;
}
// inflate the row from xml when needed
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = myInflater.inflate(R.layout.row_museum,parent, false);
return new ViewHolder(view);
}
// binding the data to the provided textview in the created custom view
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
String names = myMuseums.get(position).name; //modified
String descriptions = myMuseums.get(position).desc; //modified
holder.MuseumText.setText(names);
holder.DescriptionText.setText(descriptions);
holder.MuseumText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), MuseumNames.class);
intent.putExtra ( "selectedFruit", myMuseums.get(position).name);
v.getContext().startActivity(intent);
}
});
}
// get total items of the data
@Override
public int getItemCount() {
return myMuseums.size();
}
// create and retrieve the data as the user scrolls the list
public class ViewHolder extends RecyclerView.ViewHolder{
TextView MuseumText;
TextView DescriptionText; //add
ViewHolder(View v){
super(v);
MuseumText = itemView.findViewById(R.id.MuseumText);
DescriptionText = itemView.findViewById(R.id.DescriptionText); //add
}
}
}
\ No newline at end of file
package com.example.appppppp;
public class DetailMuseums {
}
......@@ -17,4 +17,8 @@ public class LogIn extends AppCompatActivity {
Intent back = new Intent(this, MainMenu.class);
startActivity(back);
}
public void toMuseums (View V){
Intent back = new Intent(this, MuseumList.class);
startActivity(back);
}
}
\ No newline at end of file
package com.example.appppppp;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.os.Bundle;
import java.util.ArrayList;
public class MuseumList extends AppCompatActivity {
//create private parameters
adapter adapterObj;
ArrayList<MuseumNames> dataList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_museum_list);
// data to populate the recyclerview with
dataList = new ArrayList<>();
dataList.add(new MuseumNames ("Apple", "An apple is an edible fruit produced by an apple tree."));
dataList.add(new MuseumNames ("Pear", "Pears are sweet, bell-shaped fruits that have been enjoyed since ancient times."));
dataList.add(new MuseumNames ("Pineapple", "description "));
dataList.add(new MuseumNames ("Kiwi", "description "));
dataList.add(new MuseumNames("Banana", "description "));
dataList.add(new MuseumNames("Watermelon", "description "));
// set up the recyclerview
RecyclerView recyclerObj = findViewById(R.id.recyclerID);
recyclerObj.setLayoutManager(new LinearLayoutManager(this));
adapterObj = new adapter(this, dataList);
recyclerObj.setAdapter(adapterObj);
}
}
\ No newline at end of file
package com.example.appppppp;
public class MuseumNames {
String name;
String desc;
MuseumNames(String n, String d ){
name = n;
desc = d;
}
}
This diff is collapsed.
......@@ -11,6 +11,7 @@
android:layout_width="126dp"
android:layout_height="41dp"
android:layout_marginBottom="328dp"
android:onClick="toMuseums"
android:text="Enter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
......
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MuseumList">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerID"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteX="263dp"
tools:layout_editor_absoluteY="336dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ 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/MuseumText"
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="Line1"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:textSize="18sp" />
<TextView
android:id="@+id/DescriptionText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="description of each museum" />
<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