Question: based on this xml file and java file edit the xml so the program runs as the demo video below https://watch.screencastify.com/v/cGwSMTeNi53Bpzdo2hRK) package com.example.midterm1_part2; import androidx.appcompat.app.AppCompatActivity;

based on this xml file and java file edit the xml so the program runs as the demo video below

https://watch.screencastify.com/v/cGwSMTeNi53Bpzdo2hRK)

package com.example.midterm1_part2; import androidx.appcompat.app.AppCompatActivity; import android.app.AlertDialog; import android.content.DialogInterface; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity { private TextView Header; ListView listView; String[] streamList = {"Science", "Accounting", "Arts", "Computing Science"}; private android.app.AlertDialog.Builder builder; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Initialize the ListView and set its adapter ListView listView = findViewById(R.id.list_view); String[] streams = {"Science", "Accounting", "Arts", "Computing Science"}; ArrayAdapter adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, streams); listView.setAdapter(adapter); // Set the long click listener on the ListView items listView.setOnItemLongClickListener((parent, view, position, id) -> { // Create a new AlertDialog AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle("Course details"); // Set the message based on the selected stream String stream = adapter.getItem(position); String message = ""; if (stream.equals("Science")) { message = "Physics, Chemistry, Atmospheric Sciences, Soil ecology."; } else if (stream.equals("Accounting")) { message = "Commerce, Economics, Maths, Statistics."; } else if (stream.equals("Arts")) { message = "Sociology, Political Science, History, Psychology."; } else if (stream.equals("Computing Science")) { message = "Maths, Programming 1, Microeconomics, Professional Writing."; } builder.setMessage(message); // Set the positive button and its click listener builder.setPositiveButton("Add to schedule", (dialog, which) -> { Toast.makeText(MainActivity.this, "Courses Successfully added to schedule", Toast.LENGTH_SHORT).show(); }); // Set the neutral button and its click listener builder.setNeutralButton("Select again", (dialog, which) -> { dialog.dismiss(); }); // Show the AlertDialog builder.show(); return true; }); } } 

xml file

    

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!