Commit 3efb0b6e authored by james.clarke2's avatar james.clarke2

Add new file

parent 54ae01c4
package com.example.carrentals;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import java.util.ArrayList;
import static android.widget.AdapterView.*;
public class listOfCars extends AppCompatActivity {
String items[] = new String[]{"Audi, Specifications are Power steering,power breaks, power locks,power windows, air bags, automatic air conditioning,ABS breaks, 2 people.Price = 8/hr ", "Honda, Specifications Power Locks/Windows, air bags, automatic,air conditioning, 5 people. Price = 10/hr", " Jaguar Specifications, Cruise control, leather interior, automatic, air conditioning, tilt steering wheel, power mirrors, power door locks, 4 people. Price = 10/hr", "Benz,Specifications are Power locks/windows, air bags manual hatchback, 4 people. Price = 11/hr", "Toyota, Specifications ,Manual,air conditioning,diesel, 8 people. Price 7/hr"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_of_cars);
ListView listView = (ListView) findViewById(R.id.listView);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(listOfCars.this, items[position], Toast.LENGTH_SHORT).show();
}
});
Button mButton = (Button) findViewById(R.id.button8);
mButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent( listOfCars.this, Review.class));
}
});
}
}
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