10天冲刺第八天

今天做了什么:

预约界面:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".bookActivity">
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="20dp"
        android:background="@color/white"/>
    <EditText
        android:id="@+id/ed_method"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:hint="请提交联系方式,如电话号,微信号"
        android:background="@drawable/shape_gray_square_bg"/>
    <Button
        android:id="@+id/bt_commit"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="提交"/>

</LinearLayout>

  对应  代码:

package com.example.psychological;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Looper;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.example.psychological.javaClass.Dao;

import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class bookActivity extends AppCompatActivity implements View.OnClickListener {

    private EditText ed_method;
    private Button bt_commit;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_book);
        getSupportActionBar().hide();
        ed_method = findViewById(R.id.ed_method);
        bt_commit = findViewById(R.id.bt_commit);
        bt_commit.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                Dao d =new Dao();
                SharedPreferences sharedPreferences = getSharedPreferences("data",MODE_PRIVATE);
                String bid = sharedPreferences.getString("bid","");
                sharedPreferences = getSharedPreferences("user",MODE_PRIVATE);
                String uid = sharedPreferences.getString("id","");
                String method = ed_method.getText().toString();
                SimpleDateFormat formatter= new SimpleDateFormat("MM月dd日 HH:mm");
                Date date = new Date(System.currentTimeMillis());
                if(method==null) {
                    Looper.prepare();
                    Toast.makeText(bookActivity.this,"输入为空", Toast.LENGTH_SHORT).show();
                    Looper.loop();
                }
                try {
                    d.addNotice(uid,bid,method,formatter.format(date));
                } catch (SQLException e) {
                    throw new RuntimeException(e);
                }
                finish();
                startActivity(new Intent(bookActivity.this,MainActivity.class));
            }
        }).start();
    }

  明天做什么:

咨询师通知查看功能

遇到的问题:没遇到什么问题,沿用的文章提交

posted @ 2024-04-27 19:40  umiQa  阅读(2)  评论(0编辑  收藏  举报