校园二手交易平台

关于我们的App

我们实现的功能有登录、注册、密码修改、查看修改个人信息、上传商品、查看我的发布、查看所有商品、查看某个商品的详细信息、给商家留言这几个主要的功能。

进入APP首先是登录界面,没有用户名会提示先注册,注册时会验证用户名是否已存在;登录时会验证用户名是否存在以及对应的密码是否正确。

登陆后进入首页,下边的导航栏都可以跳转实现,上面的四个商品分类导航栏用于查询该分类的商品。

个人中心页面里面的查询个人信息、修改密码、我的发布、关于我们都已实现;修改密码会判断原始密码的正确性以及把新密码修改到数据库中。

发布页面可以点击上方的ImageButton来读取手机上的图片,填写好商品的信息点击发布按钮就会把信息插入到商品表中,然后在主页和我的发布页面(会判断当前登录的用户)显示。

在首页点击商品会直接跳转到该商品的详细信息页面,下方有留言区,可以留言。

项目效果

上传商品信息插入到数据库

Button fabu=(Button)findViewById(R.id.fabu);
        fabu.setOnClickListener(new View.OnClickListener() {
            @RequiresApi(api = Build.VERSION_CODES.O)
            @Override
            public void onClick(View v) {
                EditText title=(EditText)findViewById(R.id.m1_title);
                Spinner style=(Spinner)findViewById(R.id.m1_style);
                EditText price=(EditText)findViewById(R.id.m1_price);
                EditText phone=(EditText)findViewById(R.id.m1_phone);
                EditText nr=(EditText)findViewById(R.id.m1_nr);
                Date curDate = new Date(System.currentTimeMillis());
                String str = formatter.format(curDate);
                SQLiteDatabase db=dbHelper.getWritableDatabase();
                ContentValues values=new ContentValues();
                values.put("Id",25);
                values.put("title",title.getText().toString());
//              values.put("style", style.getTooltipText().toString());
                values.put("style", str);
                values.put("time",str.toString());
                values.put("price",price.getText().toString());
                values.put("phone",phone.getText().toString());
                values.put("nr",nr.getText().toString());
                db.insert("Sc_message",null,values);
                Intent intent=new Intent(MainActivity_m1.this,MainActivity.class);
                startActivity(intent);
            }
        });

把上传数据库中的信息显示在我的发布列表中

MyDatabaseHelper mydb = new MyDatabaseHelper(this,"1600802129.db",null,1);
final SQLiteDatabase ddb = mydb.getWritableDatabase();
ListView listView = (ListView)findViewById(R.id.show_fabu);
Map<String, Object> item;
List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
Cursor cursor = db.query("Sc_message",null,null,null,null,null,null,null);
if (cursor.moveToFirst()){
    while (!cursor.isAfterLast()){
        item = new HashMap<String, Object>();
        item.put("id",cursor.getInt(0));
        item.put("title",cursor.getString(1));
        item.put("nr",cursor.getBlob(6));
        item.put("style",cursor.getBlob(2));
        item.put("time",cursor.getString(3));
        item.put("price",cursor.getString(4));
        item.put("phone",cursor.getString(5));
        cursor.moveToNext();
        data.add(item);
    }
}
SimpleAdapter simpleAdapter = new SimpleAdapter(this, data, R.layout.my_fabu, new String[] { "image", "title", "price", "pl", "ly" },
        new int[] { R.id.show_image, R.id.show_title, R.id.show_price, R.id.show_pl, R.id.show_view });
listView.setAdapter(simpleAdapter);

读取数据库中的图片并将其插入到列表中

        byte[] imagedata;
        Bitmap imagebm;
        imagedata = cursor.getBlob(6);
        imagebm = BitmapFactory.decodeByteArray(imagedata, 0, imagedata.length);
        item.put("image",imagebm);

        SimpleAdapter simpleAdapter = new SimpleAdapter(this, data, R.layout.listitem, new String[] { "image", "title", "kind", "info", "price" },
                new int[] { R.id.item_image, R.id.title, R.id.kind, R.id.info, R.id.price });
        simpleAdapter.setViewBinder(new SimpleAdapter.ViewBinder() {
            @Override
            public boolean setViewValue(View view, Object data, String textRepresentation) {
                if(view instanceof ImageView  && data instanceof Bitmap){
                    ImageView iv = (ImageView)view;
                    iv.setImageBitmap( (Bitmap)data );
                    return true;
                }else{
                    return false;
                }
            }
        });
        listView.setAdapter(simpleAdapter);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值