本站消息

站长简介/公众号


站长简介:逗比程序员,理工宅男,前每日优鲜python全栈开发工程师,利用周末时间开发出本站,欢迎关注我的微信公众号:幽默盒子,一个专注于搞笑,分享快乐的公众号

  价值13000svip视频教程,java大神匠心打造,零基础java开发工程师视频教程全套,基础+进阶+项目实战,包含课件和源码

  出租广告位,需要合作请联系站长


+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

2021-05(17)

2021-06(62)

2021-07(6)

基于Android开发二手车交易平台

发布于2021-06-12 16:11     阅读(283)     评论(0)     点赞(11)     收藏(2)


基于Android开发二手车交易平台

作者:黑衣侠客


一、前言

最近由于软工老师布置了开发二手车交易平台的作业,同时也想复习一下大一学习的Android知识,因此,这次使用了基于Android平台和leancloud网络服务器,对二手车交易平台进行开发,由于这次作业老师要求添加数据分析和数据挖掘,所以这次开发我基本上没有太大的把握,能写成什么样算什么样,和往常一样,这篇博客我会在程序开发过程中,依次进行补充,不过这篇博客,主要涵盖了我的软件开发流程,所以偏向于软工角度偏多。

二、需求分析

这次的需求分析也只是大概的一个框架,里面涵盖了这个项目的基本功能及一些老师要求上的高级需求设计:

只是一个需求说明,能不能实现就是另外一说了

销售端:

  1. 车辆信息管理
  2. 二手车的录入
  3. 二手车销售信息数据模块
  4. 客群消费分析模块

用户端:

  1. 基于网络服务器的注册登录
  2. 地理位置信息选择(联网获取)
  3. 轮播图
  4. 车辆品牌检索功能
  5. 车型分类
  6. 价格分类
  7. 限号处理(选做)

管理端:

  1. 用户管理
  2. 二手车评估入库模块
  3. 二手车维修、清理、库存模块
  4. 二手车销售信息数据分析管理模块
  5. 客群消费分析模块(最好带有图表分析
数据分析:

对数据和需求进行分析,利用合适的图表进行建模表示

数据挖掘:

还未找到平台(自选添加)

评估系统:
  1. 年限
  2. 品牌
  3. 车况
  4. 维修费用
  5. 厂家
  6. 型号
  7. 历史记录(已跑公里数)
关于数据:

不少于30个车型,按照汽车热度优先级进行顺序排列,要求记录本地区/全国过去10年的相关数据,全球过去30年的相关数据,并且可以处理异常识别异常计算等。
在这里插入图片描述

三、简单设计

这里我展示了一些目前已经开发好的程序页面:
这个是展示动画

下面是图片:








另外这里在放一张服务器的图片:

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

四、代码设计

由于这次需要对车型的基本信息进行分类,所以我写了很多个Activity对应不同的车型主题,方便对每个界面进行不同的编辑,缺点就是太麻烦了

  • 首先是对不同的依赖的添加:

在这里插入图片描述

由于还没有添加车型检索功能的API,所以这里的依赖也只是暂时的,只是提供了与网络服务器的连接,目前只是实现了利用服务器进行用户的联网注册登录,以后我会依次完善功能。

与此同时,需要注意的是:

这里需要改一下版本号,目的是为了可以将数据更方便的写入leancloud服务器。

之后在project的build.gradle中写入:
在这里插入图片描述
在这里插入图片描述
目前的结构架构是:
在这里插入图片描述

MainActivity.java:
package com.example.second_hand_car;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private ImageView find;
    /*private String[] data = { "奥迪", "阿斯顿·马丁","奔驰","宝马","保时捷","本田","宾利","别克",
    "比亚迪","布加迪","大众","丰田","福特","法拉利","红旗","捷豹",
    "劳斯莱斯","兰博基尼","路虎","马自达","玛莎拉蒂","迈巴赫","雪佛兰","北京现代","雷克萨斯"};
    */
    private List<Car> carList = new ArrayList<>();

    private ImageView benchi;
    private ImageView aodi;
    private ImageView baoma;
    private ImageView dazhong;
    private ImageView bentian;
    private ImageView leikesasi;
    private ImageView fengtian;
    private ImageView bieke;
    private ImageView woerwo;
    private ImageView lanbojini;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //设置状态栏为透明
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                    | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);
            window.setNavigationBarColor(Color.TRANSPARENT);
        }

        getSupportActionBar().hide();
        find = findViewById(R.id.find);
        benchi = findViewById(R.id.main_benchi);
        aodi = findViewById(R.id.main_aodi);
        baoma = findViewById(R.id.main_baoma);
        dazhong = findViewById(R.id.main_dazhong);
        bentian = findViewById(R.id.main_bentian);
        leikesasi = findViewById(R.id.main_leikesasi);
        fengtian = findViewById(R.id.main_fengtian);
        bieke = findViewById(R.id.main_bieke);
        woerwo = findViewById(R.id.main_woerwo);
        lanbojini = findViewById(R.id.main_lanbojini);
        find.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,findActivity.class);
                startActivity(intent);
            }
        });
        benchi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,Car_Choose.class);
                startActivity(intent);
            }
        });
        aodi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,AodiActivity.class);
                startActivity(intent);
            }
        });
        baoma.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,BaomaActivity.class);
                startActivity(intent);
            }
        });
        dazhong.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,DazhongActivity.class);
                startActivity(intent);
            }
        });
        bentian.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,BentianActivity.class);
                startActivity(intent);
            }
        });
        leikesasi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,LeikesasiActivity.class);
                startActivity(intent);
            }
        });
        fengtian.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,FengtianActivity.class);
                startActivity(intent);
            }
        });
        bieke.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,BiekeActivity.class);
                startActivity(intent);
            }
        });
        woerwo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,WoerwoActivity.class);
                startActivity(intent);
            }
        });
        lanbojini.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,LanbojiniActivity.class);
                startActivity(intent);
            }
        });
        initCars();
        CarAdapter adapter = new CarAdapter(
                MainActivity.this , R.layout.car_item, carList);
        ListView listView = findViewById(R.id.list_view);
        listView.setAdapter(adapter);

        //添加listView的点击功能

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                 Car car = carList.get(position);
                //Toast.makeText(MainActivity.this, car.getName(), Toast.LENGTH_SHORT).show();
                Intent intent = new Intent(MainActivity.this,Car_Choose.class);
                startActivity(intent);
            }
        });
    }

    //初始化车类型的30组数据

    private void initCars(){
        Car aodi = new Car("奥迪",R.drawable.aodi,"德国");
        carList.add(aodi);
        Car benchi = new Car("奔驰",R.drawable.benchi,"德国");
        carList.add(benchi);
        Car baoma = new Car("宝马",R.drawable.baoma,"德国");
        carList.add(baoma);
        Car leikesasi = new Car("雷克萨斯",R.drawable.leikesasi,"日本");
        carList.add(leikesasi);
        Car dazhong = new Car("大众",R.drawable.dazhong,"德国");
        carList.add(dazhong);
        Car bentian = new Car("本田",R.drawable.bentian,"日本");
        carList.add(bentian);
        Car fengtian = new Car("丰田",R.drawable.fengtian,"日本");
        carList.add(fengtian);
        Car bieke = new Car("别克",R.drawable.bieke,"美国");
        carList.add(bieke);
        Car woerwo = new Car("沃尔沃",R.drawable.woerwo,"瑞典");
        carList.add(woerwo);
        Car lanbojini = new Car("兰博基尼",R.drawable.lanbojini,"意大利");
        carList.add(lanbojini);
        Car asidunmading = new Car("阿斯顿·马丁",R.drawable.asidunmading,"英国");
        carList.add(asidunmading);
        Car baoshijie = new Car("保时捷",R.drawable.baoshijie,"德国");
        carList.add(baoshijie);
        Car binli = new Car("宾利",R.drawable.binli,"宾利");
        carList.add(binli);
        Car bujiadi = new Car("布加迪",R.drawable.bujiadi,"法国");
        carList.add(bujiadi);
        Car biyadi = new Car("比亚迪",R.drawable.biyadi,"比亚迪");
        carList.add(biyadi);
        Car fute = new Car("福特",R.drawable.fute,"美国");
        carList.add(fute);
        Car falali = new Car("法拉利",R.drawable.falali,"意大利");
        carList.add(falali);
        Car hongqi = new Car("红旗",R.drawable.hongqi,"中国");
        carList.add(hongqi);
        Car jiebao = new Car("捷豹",R.drawable.jiebao,"英国");
        carList.add(jiebao);
        Car laosilaisi = new Car("劳斯莱斯",R.drawable.laosilaisi,"英国");
        carList.add(laosilaisi);
        Car luhu = new Car("路虎",R.drawable.luhu,"英国");
        carList.add(luhu);
        Car mazida = new Car("马自达",R.drawable.mazida,"日本");
        carList.add(mazida);
        Car mashaladi = new Car("玛莎拉蒂",R.drawable.mashaladi,"日本");
        carList.add(mashaladi);
        Car maibahe = new Car("迈巴赫",R.drawable.maibahe,"德国");
        carList.add(maibahe);
        Car xuefulan = new Car("雪佛兰",R.drawable.xuefulan,"美国");
        carList.add(xuefulan);
        Car xiandai = new Car("现代",R.drawable.beijingxiandai,"韩国");
        carList.add(xiandai);
        Car leikesasis = new Car("雷克萨斯",R.drawable.leikesasi,"日本");
        carList.add(leikesasis);
        Car aerfaluomiou = new Car("阿尔法·罗密欧",R.drawable.aerfaluomiou,"意大利");
        carList.add(aerfaluomiou);
        Car changcheng = new Car("长城",R.drawable.changcheng,"中国");
        carList.add(changcheng);
        Car hanma = new Car("悍马",R.drawable.hanma,"美国");
        carList.add(hanma);
    }
}

Login.java:
package com.example.second_hand_car;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.Toast;

public class Login extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        getSupportActionBar().hide();
        if(Build.VERSION.SDK_INT >= 21){
            Window window = getWindow();
            window.setStatusBarColor(getResources().getColor(R.color.colorLogin));
        }
        Button login = findViewById(R.id.login);
        login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Login.this,Login2.class);
                startActivity(intent);
            }
        });
        Button login2 = findViewById(R.id.login2);
        login2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Toast.makeText(Login.this, "游客登录", Toast.LENGTH_SHORT).show();
                Intent intent = new Intent(Login.this,ViewPagerActivity.class);
                startActivity(intent);
            }
        });
    }
}

Login2.java:
package com.example.second_hand_car;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVUser;
import com.avos.avoscloud.LogInCallback;

public class Login2 extends AppCompatActivity {
    private EditText name;
    private EditText password;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login2);
        if(Build.VERSION.SDK_INT >= 21 ){
            Window window = getWindow();
            window.setStatusBarColor(getResources().getColor(R.color.colorHead));
        }
        getSupportActionBar().hide();
        Button login = findViewById(R.id.yonghu_login);
        name = findViewById(R.id.yonghuming);
        password = findViewById(R.id.mima);
        login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Toast.makeText(Login2.this, "登录成功", Toast.LENGTH_SHORT).show();
                if(!name.getText().toString().equals("")&&!password.getText().toString().equals("")){
                    AVUser.logInInBackground(name.getText().toString(), password.getText().toString(), new LogInCallback<AVUser>() {
                        @Override
                        public void done(AVUser avUser, AVException e) {
                            if(e==null){
                                startActivity(new Intent(Login2.this,ViewPagerActivity.class));
                                finish();
                            }else{
                                Toast.makeText(Login2.this, "用户名或密码错误", Toast.LENGTH_SHORT).show();
                            }
                        }
                    });
                }else{
                    if(name.getText().toString().equals("")&&password.getText().toString().equals("")){
                        Toast.makeText(Login2.this, "请输入用户名和用户密码", Toast.LENGTH_SHORT).show();
                    }else if(name.getText().toString().equals("")&&!password.getText().toString().equals("")){
                        Toast.makeText(Login2.this, "请输入用户名", Toast.LENGTH_SHORT).show();
                    }else if(!name.getText().toString().equals("")&&password.getText().toString().equals("")){
                        Toast.makeText(Login2.this, "请输入用户密码" , Toast.LENGTH_SHORT).show();
                    }
                }
            }
        });
        Button register = findViewById(R.id.register);
        register.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Toast.makeText(Login2.this, "注册成功", Toast.LENGTH_SHORT).show();
                Intent intent = new Intent(Login2.this,Register.class);
                startActivity(intent);
            }
        });
    }
}

Register.java:
package com.example.second_hand_car;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVUser;
import com.avos.avoscloud.SignUpCallback;

public class Register extends AppCompatActivity implements View.OnClickListener{
    private Button register1,cancel;
    private EditText name,email,password,confirmation;
    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        getSupportActionBar().hide();
        if(Build.VERSION.SDK_INT >= 21){
            Window window = getWindow();
            window.setStatusBarColor(getResources().getColor(R.color.colorLogin));
        }
        register1 = findViewById(R.id.user_register);
        cancel = findViewById(R.id.cancel);
        name = findViewById(R.id.registername);
        email = findViewById(R.id.registeremail);
        password = findViewById(R.id.registerpassword);
        confirmation = findViewById(R.id.confirmation);
        register1.setOnClickListener(this);
        cancel.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch(v.getId()){
            case R.id.user_register:
                String str1 = password.getText().toString();
                String str2 = confirmation.getText().toString();
                String str3 = name.getText().toString();
                String str4 = email.getText().toString();
                if(str1.equals("")&&str2.equals("")&&str3.equals("")&&str4.equals("")){
                    Toast.makeText(this, "请输入用户信息", Toast.LENGTH_SHORT).show();
                }else if(str1.equals("")||str2.equals("")||str3.equals("")||str4.equals("")){
                    if(str3.equals("")){
                        Toast.makeText(this, "请输入用户名", Toast.LENGTH_SHORT).show();
                    }
                    else if(str4.equals("")){
                        Toast.makeText(this, "请输入邮箱地址", Toast.LENGTH_SHORT).show();
                    }
                    else if(str1.equals("")){
                        Toast.makeText(this, "请输入密码", Toast.LENGTH_SHORT).show();
                    }
                    else if(str2.equals("")){
                        Toast.makeText(this, "请确认密码", Toast.LENGTH_SHORT).show();
                    }
                }else if (str1.equals(str2)&&!str1.equals("")&&!str3.equals("")&&!str4.equals("")){
                    //Toast.makeText(this, "注册成功", Toast.LENGTH_SHORT).show();
                    AVUser user = new AVUser();
                    user.setUsername(name.getText().toString());
                    user.setEmail(email.getText().toString());
                    user.setPassword(password.getText().toString());
                    user.signUpInBackground(new SignUpCallback() {
                        @Override
                        public void done(AVException e) {
                            if(e==null){
                                startActivity(new Intent(Register.this,Login2.class));
                                finish();
                            }else{
                                Toast.makeText(Register.this, "邮箱规格不符", Toast.LENGTH_SHORT).show();
                            }
                        }
                    });
                }else{
                    Toast.makeText(this, "两次密码输入不一致,请重新输入", Toast.LENGTH_SHORT).show();
                }
                break;
            case R.id.cancel:
                finish();
                break;
        }
    }
}


SplashActivity.java:
package com.example.second_hand_car;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.Window;

public class SplashActivity extends AppCompatActivity {
    private static int SPLASH_DISPLAY_LENGHT = 2000;//延迟时间
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getSupportActionBar().hide();//去掉标题
        setContentView(R.layout.activity_splash);
        if(Build.VERSION.SDK_INT >= 21){
            Window window = getWindow();
            window.setStatusBarColor(getResources().getColor(R.color.colorred));
        }
        new Handler().postDelayed(new Runnable() {//利用线程延时来做处理
            @Override
            public void run() {
                Intent intent = new Intent(SplashActivity.this, Login.class);
                startActivity(intent);
                SplashActivity.this.finish();
            }
        },SPLASH_DISPLAY_LENGHT);
    }
}

Car.java:
package com.example.second_hand_car;

//创建车类

public class Car {
    private String name;
    private int imageId;
    private String nation;

    public Car(String name, int imageId, String nation){
        this.name = name;
        this.imageId = imageId;
        this.nation = nation;
    }

    public String getName(){
        return name;
    }

    public int getImageId(){
        return imageId;
    }

    public String getNation(){
        return nation;
    }
}

Car_Choose.java:
package com.example.second_hand_car;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

public class Car_Choose extends AppCompatActivity {

    private ImageView picture;

    private List<Car_Information> information = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_car__choose);
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                    | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);
            window.setNavigationBarColor(Color.TRANSPARENT);
        }
        initInformations();

        getSupportActionBar().hide();
        Car_Information_Adapter adapter = new Car_Information_Adapter(Car_Choose.this,R.layout.car_information_item,information);
        ListView listView = findViewById(R.id.benchibuju);
        listView.setAdapter(adapter);


    }

    private void initInformations(){
        Car_Information benchiAji = new Car_Information("奔驰A级","21.18-29.98万","紧凑型车",R.drawable.benchi1);
        information.add(benchiAji);
        Car_Information benchiAjiAMG = new Car_Information("奔驰A级AMG","39.98万","紧凑型车",R.drawable.benchi2);
        information.add(benchiAjiAMG);
        Car_Information benchiGLA = new Car_Information("奔驰GLA","27.68-33.28万","紧凑型SUV",R.drawable.benchi3);
        information.add(benchiGLA);
        Car_Information benchiGLB = new Car_Information("奔驰GLB","29.28-34.88万","紧凑型SUV",R.drawable.benchi4);
        information.add(benchiGLB);
        Car_Information benchiCLA = new Car_Information("奔驰CLA","29.79-38.58万","紧凑型车",R.drawable.benchi5);
        information.add(benchiCLA);
        Car_Information benchiGEL = new Car_Information("奔驰GEL","68.55-91.78万","中大型SUV",R.drawable.benchi6);
        information.add(benchiGEL);
        Car_Information benchiG = new Car_Information("奔驰G级","142.98-189.88万","中大型SUV",R.drawable.benchi7);
        information.add(benchiG);
        Car_Information benchiAjiAMGs = new Car_Information("奔驰A级AMG","39.98-57.98万","紧凑型车",R.drawable.benchi8);
        information.add(benchiAjiAMGs);
        Car_Information benchimabahe = new Car_Information("迈巴赫S级","145.88-146.80万","豪华型车",R.drawable.benchi9);
        information.add(benchimabahe);
        Car_Information benchiGAMG = new Car_Information("奔驰G级AMG","222.88-245.88万","中大型SUV",R.drawable.benchi10);
        information.add(benchiGAMG);
    }
}

Car_Information:
package com.example.second_hand_car;

import android.media.Image;

public class Car_Information {
    private int ImageId;
    private String name;
    private String price;
    private String leixing;

    public Car_Information(String name,String price,String leixing,int ImageId){
        this.name = name;
        this.price = price;
        this.leixing = leixing;
        this.ImageId = ImageId;
    }

    public String getName(){
        return name;
    }

    public String getPrice(){
        return price;
    }

    public String getLeixing(){
        return leixing;
    }

    public int getImageId(){
        return ImageId;
    }
}

Car_Information_Adapter.java:
package com.example.second_hand_car;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.List;

//车类选择适配器

public class Car_Information_Adapter extends ArrayAdapter<Car_Information> {

    private int resourceId;

    public Car_Information_Adapter(Context context, int textViewResourceId, List<Car_Information> objects){
        super(context, textViewResourceId, objects);
        resourceId = textViewResourceId;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        Car_Information car = getItem(position);
        //优化ListView的效率
        View view;
        if(convertView == null) {
            view = LayoutInflater.from(getContext()).inflate(resourceId, parent, false);
        }else{
            view = convertView;
        }
        ImageView carImage = view.findViewById(R.id.car_information_picture);
        TextView carName = view.findViewById(R.id.car_information_name);
//        TextView carPrice = view.findViewById(R.id.car_information_picture);
        TextView carleixing = view.findViewById(R.id.car_information_leixing);
        carImage.setImageResource(car.getImageId());
        carName.setText(car.getName());
        //carPrice.setText(car.getPrice());
        carleixing.setText(car.getLeixing());
        return view;
    }

}

CarAdapter.java:
package com.example.second_hand_car;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.List;

//创建一个车类的适配器

public class CarAdapter extends ArrayAdapter<Car> {
    private int resourceId;

    public CarAdapter(Context context, int textViewResourceId, List<Car> objects){
        super(context, textViewResourceId, objects);
        resourceId = textViewResourceId;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        Car car = getItem(position);
        //优化ListView的效率
        View view;
        if(convertView == null) {
            view = LayoutInflater.from(getContext()).inflate(resourceId, parent, false);
        }else{
            view = convertView;
        }
        ImageView carImage = view.findViewById(R.id.car_image);
        TextView carName = view.findViewById(R.id.car_name);
        TextView carNation = view.findViewById(R.id.car_nation);
        carImage.setImageResource(car.getImageId());
        carName.setText(car.getName());
        carNation.setText(car.getNation());
        return view;
    }
}

ViewPagerActivity.java:
package com.example.second_hand_car;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;

import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

public class ViewPagerActivity extends AppCompatActivity implements View.OnClickListener{

    private List<Car> carList = new ArrayList<>();
    private ArrayList<View> list = new ArrayList<View>();
    private ViewPager viewPager;
    private ArrayList<View> pageview;
    private LinearLayout xuanche;
    private LinearLayout zhuye;
    private LinearLayout zixun;
    private int currIndex = 0;

    //下面是车型库界面的类型
    private ImageView find;
    private ImageView benchi;
    private ImageView aodi;
    private ImageView baoma;
    private ImageView dazhong;
    private ImageView bentian;
    private ImageView leikesasi;
    private ImageView fengtian;
    private ImageView bieke;
    private ImageView woerwo;
    private ImageView lanbojini;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view_pager);

        //设置状态栏为透明
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                    | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);
            window.setNavigationBarColor(Color.TRANSPARENT);
        }

        getSupportActionBar().hide();
        viewPager = findViewById(R.id.viewPager);
        //Intent intent1 = new Intent(this,MainActivity.class);
        LayoutInflater inflater = getLayoutInflater();
        View view1 = inflater.inflate(R.layout.activity_main,null);
        View view2 = inflater.inflate(R.layout.activity_the_main,null);
        View view3 = inflater.inflate(R.layout.activity_the_news,null);
        xuanche = findViewById(R.id.xuanche);
        zhuye = findViewById(R.id.shouye);
        zixun = findViewById(R.id.zixun);
        xuanche.setOnClickListener(this);
        zhuye.setOnClickListener(this);
        zixun.setOnClickListener(this);
        pageview = new ArrayList<View>();
        //添加想要切换的页面
        pageview.add(view1);
        pageview.add(view2);
        pageview.add(view3);

        //数据适配器
        PagerAdapter mPagerAdapter = new PagerAdapter() {

            //获取当前的窗体界面数
            @Override
            public int getCount() {
                return pageview.size();
            }

            //判断是否由对象生成界面
            @Override
            public boolean isViewFromObject(@NonNull View arg0, @NonNull Object arg1) {
                return arg0==arg1;
            }

            //使从ViewGroup中移出当前的View
            public void destroyItem(View arg0,int arg1,Object arg2){
                ((ViewPager)arg0).removeView(pageview.get(arg1));
            }

            //返回一个对象,这个对象表明了PagerAdapter适配器选择哪个对象放在当前的ViewPager中
            public Object instantiateItem(View arg0,int arg1){
                ((ViewPager)arg0).addView(pageview.get(arg1));
                //处理功能实例化
                switch(arg1){
                    case 0:
                        initCars();
                        CarAdapter adapter = new CarAdapter(
                                ViewPagerActivity.this , R.layout.car_item, carList);
                        ListView listView = findViewById(R.id.list_view);
                        listView.setAdapter(adapter);

                        //添加listView的点击功能

                        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                            @Override
                            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                                Car car = carList.get(position);
                                //Toast.makeText(MainActivity.this, car.getName(), Toast.LENGTH_SHORT).show();
                                Intent intent = new Intent(ViewPagerActivity.this,Car_Choose.class);
                                startActivity(intent);
                            }
                        });
                        find = findViewById(R.id.find);
                        benchi = findViewById(R.id.main_benchi);
                        aodi = findViewById(R.id.main_aodi);
                        baoma = findViewById(R.id.main_baoma);
                        dazhong = findViewById(R.id.main_dazhong);
                        bentian = findViewById(R.id.main_bentian);
                        leikesasi = findViewById(R.id.main_leikesasi);
                        fengtian = findViewById(R.id.main_fengtian);
                        bieke = findViewById(R.id.main_bieke);
                        woerwo = findViewById(R.id.main_woerwo);
                        lanbojini = findViewById(R.id.main_lanbojini);
                        find.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                Intent intent = new Intent(ViewPagerActivity.this,findActivity.class);
                                startActivity(intent);
                            }
                        });
                        benchi.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                Intent intent = new Intent(ViewPagerActivity.this,Car_Choose.class);
                                startActivity(intent);
                            }
                        });
                        aodi.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                Intent intent = new Intent(ViewPagerActivity.this,AodiActivity.class);
                                startActivity(intent);
                            }
                        });
                        baoma.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                Intent intent = new Intent(ViewPagerActivity.this,BaomaActivity.class);
                                startActivity(intent);
                            }
                        });
                        dazhong.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                Intent intent = new Intent(ViewPagerActivity.this,DazhongActivity.class);
                                startActivity(intent);
                            }
                        });
                        bentian.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                Intent intent = new Intent(ViewPagerActivity.this,BentianActivity.class);
                                startActivity(intent);
                            }
                        });
                        leikesasi.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                Intent intent = new Intent(ViewPagerActivity.this,LeikesasiActivity.class);
                                startActivity(intent);
                            }
                        });
                        fengtian.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                Intent intent = new Intent(ViewPagerActivity.this,FengtianActivity.class);
                                startActivity(intent);
                            }
                        });
                        bieke.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                Intent intent = new Intent(ViewPagerActivity.this,BiekeActivity.class);
                                startActivity(intent);
                            }
                        });
                        woerwo.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                Intent intent = new Intent(ViewPagerActivity.this,WoerwoActivity.class);
                                startActivity(intent);
                            }
                        });
                        lanbojini.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                Intent intent = new Intent(ViewPagerActivity.this,LanbojiniActivity.class);
                                startActivity(intent);
                            }
                        });
                        break;
                    default:
                        break;
                }
                return pageview.get(arg1);
            }
        };
        //绑定适配器
        viewPager.setAdapter(mPagerAdapter);
        //设置viewPager的初始化界面为第一界面
        viewPager.setCurrentItem(0);
        //添加切换界面的监听器
        DisplayMetrics displayMetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    }

    @Override
    public void onClick(View v) {
        switch(v.getId()){
            case R.id.xuanche:
                viewPager.setCurrentItem(0);
                break;
            case R.id.shouye:
                viewPager.setCurrentItem(1);
                break;
            case R.id.zixun:
                viewPager.setCurrentItem(2);
                break;
        }
    }

    //初始化车类型的30组数据

    private void initCars(){
        Car aodi = new Car("奥迪",R.drawable.aodi,"德国");
        carList.add(aodi);
        Car benchi = new Car("奔驰",R.drawable.benchi,"德国");
        carList.add(benchi);
        Car baoma = new Car("宝马",R.drawable.baoma,"德国");
        carList.add(baoma);
        Car leikesasi = new Car("雷克萨斯",R.drawable.leikesasi,"日本");
        carList.add(leikesasi);
        Car dazhong = new Car("大众",R.drawable.dazhong,"德国");
        carList.add(dazhong);
        Car bentian = new Car("本田",R.drawable.bentian,"日本");
        carList.add(bentian);
        Car fengtian = new Car("丰田",R.drawable.fengtian,"日本");
        carList.add(fengtian);
        Car bieke = new Car("别克",R.drawable.bieke,"美国");
        carList.add(bieke);
        Car woerwo = new Car("沃尔沃",R.drawable.woerwo,"瑞典");
        carList.add(woerwo);
        Car lanbojini = new Car("兰博基尼",R.drawable.lanbojini,"意大利");
        carList.add(lanbojini);
        Car asidunmading = new Car("阿斯顿·马丁",R.drawable.asidunmading,"英国");
        carList.add(asidunmading);
        Car baoshijie = new Car("保时捷",R.drawable.baoshijie,"德国");
        carList.add(baoshijie);
        Car binli = new Car("宾利",R.drawable.binli,"宾利");
        carList.add(binli);
        Car bujiadi = new Car("布加迪",R.drawable.bujiadi,"法国");
        carList.add(bujiadi);
        Car biyadi = new Car("比亚迪",R.drawable.biyadi,"比亚迪");
        carList.add(biyadi);
        Car fute = new Car("福特",R.drawable.fute,"美国");
        carList.add(fute);
        Car falali = new Car("法拉利",R.drawable.falali,"意大利");
        carList.add(falali);
        Car hongqi = new Car("红旗",R.drawable.hongqi,"中国");
        carList.add(hongqi);
        Car jiebao = new Car("捷豹",R.drawable.jiebao,"英国");
        carList.add(jiebao);
        Car laosilaisi = new Car("劳斯莱斯",R.drawable.laosilaisi,"英国");
        carList.add(laosilaisi);
        Car luhu = new Car("路虎",R.drawable.luhu,"英国");
        carList.add(luhu);
        Car mazida = new Car("马自达",R.drawable.mazida,"日本");
        carList.add(mazida);
        Car mashaladi = new Car("玛莎拉蒂",R.drawable.mashaladi,"日本");
        carList.add(mashaladi);
        Car maibahe = new Car("迈巴赫",R.drawable.maibahe,"德国");
        carList.add(maibahe);
        Car xuefulan = new Car("雪佛兰",R.drawable.xuefulan,"美国");
        carList.add(xuefulan);
        Car xiandai = new Car("现代",R.drawable.beijingxiandai,"韩国");
        carList.add(xiandai);
        Car leikesasis = new Car("雷克萨斯",R.drawable.leikesasi,"日本");
        carList.add(leikesasis);
        Car aerfaluomiou = new Car("阿尔法·罗密欧",R.drawable.aerfaluomiou,"意大利");
        carList.add(aerfaluomiou);
        Car changcheng = new Car("长城",R.drawable.changcheng,"中国");
        carList.add(changcheng);
        Car hanma = new Car("悍马",R.drawable.hanma,"美国");
        carList.add(hanma);
    }
}

AodiActivity.java:
package com.example.second_hand_car;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

public class AodiActivity extends AppCompatActivity {

    private ImageView picture;

    private List<Car_Information> information = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_aodi);
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                    | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);
            window.setNavigationBarColor(Color.TRANSPARENT);
        }
        initInformations();

        getSupportActionBar().hide();
        Car_Information_Adapter adapter = new Car_Information_Adapter(AodiActivity.this,R.layout.car_information_item,information);
        ListView listView = findViewById(R.id.benchibuju);
        listView.setAdapter(adapter);


    }

    private void initInformations(){
        Car_Information benchiAji = new Car_Information("奥迪A3","20.31-24.97万","紧凑型车",R.drawable.aodi1);
        information.add(benchiAji);
        Car_Information benchiAjiAMG = new Car_Information("奥迪A4L","30.58-39.68万","中型车",R.drawable.aodi2);
        information.add(benchiAjiAMG);
        Car_Information benchiGLA = new Car_Information("奥迪A6L","41.78-66.68万","中大型车",R.drawable.aodi3);
        information.add(benchiGLA);
        Car_Information benchiGLB = new Car_Information("奥迪A6L新能源","50.80万","中大型车",R.drawable.aodi4);
        information.add(benchiGLB);
        Car_Information benchiCLA = new Car_Information("奥迪Q2L","21.77-26.50万","小型SUV",R.drawable.aodi5);
        information.add(benchiCLA);
        Car_Information benchiGEL = new Car_Information("奥迪Q2L e-tron","22.68-23.73万","小型SUV",R.drawable.aodi6);
        information.add(benchiGEL);
        Car_Information benchiG = new Car_Information("奥迪Q3","27.43-36.18万","紧凑型SUV",R.drawable.aodi7);
        information.add(benchiG);
        Car_Information benchiAjiAMGs = new Car_Information("奥迪Q3 Sportback","28.73-36.18万","紧凑型SUV",R.drawable.aodi8);
        information.add(benchiAjiAMGs);
        Car_Information benchimabahe = new Car_Information("奥迪Q5L","38.78-49.80万","中型SUV",R.drawable.aodi9);
        information.add(benchimabahe);
        Car_Information benchiGAMG = new Car_Information("奥迪Q5L Sportback","42.68-49.99万","中型SUV",R.drawable.aodi10);
        information.add(benchiGAMG);
    }
}

BaomaActivity.java:
package com.example.second_hand_car;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

public class BaomaActivity extends AppCompatActivity {

    private ImageView picture;

    private List<Car_Information> information = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_baoma);
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                    | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);
            window.setNavigationBarColor(Color.TRANSPARENT);
        }
        initInformations();

        getSupportActionBar().hide();
        Car_Information_Adapter adapter =new Car_Information_Adapter(BaomaActivity.this,R.layout.car_information_item,information);
        ListView listView = findViewById(R.id.benchibuju);
        listView.setAdapter(adapter);


    }

    private void initInformations(){
        Car_Information benchiAji = new Car_Information("宝马1系","19.98-24.68万","紧凑型车",R.drawable.baoma1);
        information.add(benchiAji);
        Car_Information benchiAjiAMG = new Car_Information("宝马3系","29.39-40.99万","中型车",R.drawable.baoma2);
        information.add(benchiAjiAMG);
        Car_Information benchiGLA = new Car_Information("宝马5系","42.19-54.99万","中大型车",R.drawable.baoma3);
        information.add(benchiGLA);
        Car_Information benchiGLB = new Car_Information("宝马5系新能源","49.99-53.69万","中大型车",R.drawable.baoma4);
        information.add(benchiGLB);
        Car_Information benchiCLA = new Car_Information("宝马X1","21.77-26.50万","紧凑型SUV",R.drawable.baoma5);
        information.add(benchiCLA);
        Car_Information benchiGEL = new Car_Information("宝马X2","22.68-23.73万","紧凑型SUV",R.drawable.baoma6);
        information.add(benchiGEL);
        Car_Information benchiG = new Car_Information("宝马X1新能源","39.98万","紧凑型SUV",R.drawable.baoma7);
        information.add(benchiG);
        Car_Information benchiAjiAMGs = new Car_Information("宝马X3","38.98-47.98万","中型SUV",R.drawable.baoma8);
        information.add(benchiAjiAMGs);
        Car_Information benchimabahe = new Car_Information("宝马iX3","39.99-43.99万","中型SUV",R.drawable.baoma9);
        information.add(benchimabahe);
        Car_Information benchiGAMG = new Car_Information("宝马X5新能源","85.99万","中大型SUV",R.drawable.baoma10);
        information.add(benchiGAMG);
    }
}


BentianActivity.java:
package com.example.second_hand_car;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

public class BaomaActivity extends AppCompatActivity {

    private ImageView picture;

    private List<Car_Information> information = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_baoma);
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                    | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);
            window.setNavigationBarColor(Color.TRANSPARENT);
        }
        initInformations();

        getSupportActionBar().hide();
        Car_Information_Adapter adapter =new Car_Information_Adapter(BaomaActivity.this,R.layout.car_information_item,information);
        ListView listView = findViewById(R.id.benchibuju);
        listView.setAdapter(adapter);


    }

    private void initInformations(){
        Car_Information benchiAji = new Car_Information("宝马1系","19.98-24.68万","紧凑型车",R.drawable.baoma1);
        information.add(benchiAji);
        Car_Information benchiAjiAMG = new Car_Information("宝马3系","29.39-40.99万","中型车",R.drawable.baoma2);
        information.add(benchiAjiAMG);
        Car_Information benchiGLA = new Car_Information("宝马5系","42.19-54.99万","中大型车",R.drawable.baoma3);
        information.add(benchiGLA);
        Car_Information benchiGLB = new Car_Information("宝马5系新能源","49.99-53.69万","中大型车",R.drawable.baoma4);
        information.add(benchiGLB);
        Car_Information benchiCLA = new Car_Information("宝马X1","21.77-26.50万","紧凑型SUV",R.drawable.baoma5);
        information.add(benchiCLA);
        Car_Information benchiGEL = new Car_Information("宝马X2","22.68-23.73万","紧凑型SUV",R.drawable.baoma6);
        information.add(benchiGEL);
        Car_Information benchiG = new Car_Information("宝马X1新能源","39.98万","紧凑型SUV",R.drawable.baoma7);
        information.add(benchiG);
        Car_Information benchiAjiAMGs = new Car_Information("宝马X3","38.98-47.98万","中型SUV",R.drawable.baoma8);
        information.add(benchiAjiAMGs);
        Car_Information benchimabahe = new Car_Information("宝马iX3","39.99-43.99万","中型SUV",R.drawable.baoma9);
        information.add(benchimabahe);
        Car_Information benchiGAMG = new Car_Information("宝马X5新能源","85.99万","中大型SUV",R.drawable.baoma10);
        information.add(benchiGAMG);
    }
}


BentianActivity.java:
package com.example.second_hand_car;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

public class BentianActivity extends AppCompatActivity {

    private ImageView picture;

    private List<Car_Information> information = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bentian);
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                    | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);
            window.setNavigationBarColor(Color.TRANSPARENT);
        }
        initInformations();

        getSupportActionBar().hide();
        Car_Information_Adapter adapter = new Car_Information_Adapter(BentianActivity.this,R.layout.car_information_item,information);
        ListView listView = findViewById(R.id.benchibuju);
        listView.setAdapter(adapter);


    }

    private void initInformations(){
        Car_Information benchiAji = new Car_Information("思域","11.99-16.99万","紧凑型车",R.drawable.bentian1);
        information.add(benchiAji);
        Car_Information benchiAjiAMG = new Car_Information("雅阁","17.98-25.98万","中型车",R.drawable.bentian2);
        information.add(benchiAjiAMG);
        Car_Information benchiGLA = new Car_Information("本田CR-V","16.98-27.68万","紧凑型SUV",R.drawable.bentian3);
        information.add(benchiGLA);
        Car_Information benchiGLB = new Car_Information("本田XR-V","12.79-17.59万","小型SUV",R.drawable.bentian4);
        information.add(benchiGLB);
        Car_Information benchiCLA = new Car_Information("皓影","16.98-25.28万","紧凑型车",R.drawable.bentian5);
        information.add(benchiCLA);
        Car_Information benchiGEL = new Car_Information("飞度","8.18-10.88万","小型车",R.drawable.bentian6);
        information.add(benchiGEL);
        Car_Information benchiG = new Car_Information("缤智","12.78-17.68万","小型SUV",R.drawable.bentian7);
        information.add(benchiG);
        Car_Information benchiAjiAMGs = new Car_Information("奥德赛","22.98-37.68万","MPV",R.drawable.bentian8);
        information.add(benchiAjiAMGs);
        Car_Information benchimabahe = new Car_Information("冠道","22.00-33.28万","中型SUV",R.drawable.bentian9);
        information.add(benchimabahe);
        Car_Information benchiGAMG = new Car_Information("INSPIRE","18.28-24.98万","中型车",R.drawable.bentian10);
        information.add(benchiGAMG);
    }
}

每个类型的Activity结构都差不多,这里只给出几个大概的结构和数据,其他的类型如果想继续做的话,可以根据以上Activity的结构进行修改添加数据

MyLeanCloudApp.java:
package com.example.second_hand_car;

import android.app.Application;

import com.avos.avoscloud.AVOSCloud;

public class MyLeanCloudApp extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        AVOSCloud.initialize(this,"AppId","Key");//具体数据从leancloud中导入
    }
}

布局文件我就不再博客里写了,以后写好项目之后,我会贴出github的地址,以供参考。

目前的功能还不完善,以后我会继续更新博客的。

五、查阅资料及报错时解决方法

原文链接:https://blog.csdn.net/weixin_44900700/article/details/117665590



所属网站分类: 技术文章 > 博客

作者:我睡觉爱打呼噜

链接:http://www.javaheidong.com/blog/article/222518/f39400f0344bb650fff8/

来源:java黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

11 0
收藏该文
已收藏

评论内容:(最多支持255个字符)