fixed double dish list

This commit is contained in:
LilleBRG 2025-04-28 13:59:47 +02:00
parent 4f5c0de725
commit 1aa98f2bcf
2 changed files with 0 additions and 36 deletions

View File

@ -36,27 +36,6 @@ class MainActivity : AppCompatActivity() {
setupActionBarWithNavController(navController, appBarConfiguration)
navView.setupWithNavController(navController)
val listView: ListView = findViewById(R.id.dishesList)
val listItems = arrayOf(
Dish("Spaghetti Bolognese", "Beef", 70.5),
Dish("Margherita Pizza", "Cheese", 60.0),
Dish("Chicken Curry", "Chicken", 80.2),
Dish("Vegetable Stir Fry", "Mixed Vegetables", 50.5),
Dish("Sushi", "Fish", 100.0),
Dish("Beef Tacos", "Beef", 60.8),
Dish("Lentil Soup", "Lentils", 40.5),
Dish("Pasta Alfredo", "Cream", 60.9),
Dish("Caesar Salad", "Chicken", 50.8),
Dish("Falafel Wrap", "Chickpeas", 50.2)
)
val listAdapter = DishAdapter(this, listItems)
listView.adapter = listAdapter
listView.setOnItemClickListener { parent, view, position, id ->
val selectedItem = parent.getItemAtPosition(position) as Dish
Toast.makeText(this, "you selected $selectedItem.name that costs ${selectedItem.expense} kr.", Toast.LENGTH_LONG).show()
}
findViewById<FloatingActionButton>(R.id.add_dish).setOnClickListener {
val intent = Intent(this, CreateDishActivity::class.java)

View File

@ -21,21 +21,6 @@
app:layout_constraintEnd_toEndOf="parent" />
<!-- Navigation Fragment -->
<ListView
android:id="@+id/dishesList"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0">
</ListView>
<!-- Navigation Fragment -->
<fragment
android:id="@+id/nav_host_fragment_activity_main"
android:name="androidx.navigation.fragment.NavHostFragment"