10天衝刺第三天

umiQa發表於2024-04-22

今天做了什麼:

把個人中心介面弄完了,因為其他活動介面還沒做,就每個按鈕功能姑且是跳轉回主頁面,名字和手機號是要用登入時快取的資料

這是個人中心頁面程式碼

<?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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".ui.notifications.NotificationsFragment">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <ImageView
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:background="@drawable/p1"
            android:src="@drawable/circle_images"/>

        <LinearLayout
            android:layout_width="255dp"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <TextView
                android:id="@+id/tx_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="暱稱:eee"
                android:textSize="30dp" />

            <TextView
                android:id="@+id/tx_phnumber"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="手機號:1111****111"
                android:textSize="20dp" />
        </LinearLayout>
        <ImageButton
            android:id="@+id/ibt_update"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:background="@drawable/shape_gray_square_bg"
            android:src="@drawable/baseline_mode_24"/>
    </LinearLayout>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="0.5dp"
        android:background="@color/black"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="20dp"
        android:background="@color/white"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="0.5dp"
        android:background="@color/black"/>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_gravity="center_horizontal">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="80dp"
            android:orientation="horizontal">
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:orientation="vertical">
                <ImageButton
                    android:id="@+id/ibt_add_text"
                    android:layout_width="wrap_content"
                    android:layout_height="60dp"
                    android:src="@drawable/baseline_add_comment_24"
                    android:background="@color/white"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="20dp"
                    android:layout_gravity="center_horizontal"
                    android:text="社群投稿"
                    android:textSize="10dp"/>
            </LinearLayout>
            <ImageView
                android:layout_width="20dp"
                android:layout_height="match_parent"/>
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:orientation="vertical">
                <ImageButton
                    android:id="@+id/ibt_apply"
                    android:layout_width="wrap_content"
                    android:layout_height="60dp"
                    android:src="@drawable/baseline_co_present_24"
                    android:background="@color/white"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="20dp"
                    android:layout_gravity="center_horizontal"
                    android:text="諮詢師申請"
                    android:textSize="10dp"/>
            </LinearLayout>
            <ImageView
                android:layout_width="20dp"
                android:layout_height="match_parent"/>
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:orientation="vertical">
                <ImageButton
                    android:id="@+id/ibt_record"
                    android:layout_width="wrap_content"
                    android:layout_height="60dp"
                    android:src="@drawable/baseline_text_snippet_24"
                    android:background="@color/white"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="20dp"
                    android:layout_gravity="center_horizontal"
                    android:text="每日記錄"
                    android:textSize="10dp"/>
            </LinearLayout>
            <ImageView
                android:layout_width="20dp"
                android:layout_height="match_parent"/>
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:orientation="vertical">
                <ImageButton
                    android:id="@+id/ibt_notice"
                    android:layout_width="wrap_content"
                    android:layout_height="60dp"
                    android:src="@drawable/baseline_notifications_24"
                    android:background="@color/white"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="20dp"
                    android:layout_gravity="center_horizontal"
                    android:text="通知"
                    android:textSize="10dp"/>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <Button
            android:id="@+id/bt_approve"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:gravity="center_vertical"
            android:drawableRight="@drawable/baseline_chevron_right_24"
            android:text="管理員:諮詢師申請審批"/>
    </RelativeLayout>
</LinearLayout>

  

活動介面程式碼

package com.example.psychological.ui.notifications;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;

import com.example.psychological.MainActivity;
import com.example.psychological.R;
import com.example.psychological.databinding.FragmentNotificationsBinding;

public class NotificationsFragment extends Fragment {

    private FragmentNotificationsBinding binding;
    private TextView tx_name;
    private TextView tx_phnumber;
    private ImageButton ibt_update;
    private ImageButton ibt_add_text;
    private ImageButton ibt_apply;
    private ImageButton ibt_record;
    private ImageButton ibt_notice;
    private Button bt_approve;

    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        NotificationsViewModel notificationsViewModel =
                new ViewModelProvider(this).get(NotificationsViewModel.class);

        binding = FragmentNotificationsBinding.inflate(inflater, container, false);
        View root = binding.getRoot();
        tx_name = root.findViewById(R.id.tx_name);
        tx_phnumber = root.findViewById(R.id.tx_phnumber);
        ibt_add_text = root.findViewById(R.id.ibt_add_text);
        ibt_apply = root.findViewById(R.id.ibt_apply);
        ibt_notice = root.findViewById(R.id.ibt_notice);
        ibt_record = root.findViewById(R.id.ibt_record);
        ibt_update = root.findViewById(R.id.ibt_update);
        ibt_update.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), MainActivity.class));
            }
        });
        ibt_update.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), MainActivity.class));
            }
        });
        ibt_record.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), MainActivity.class));
            }
        });
        ibt_notice.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), MainActivity.class));
            }
        });
        ibt_apply.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), MainActivity.class));
            }
        });
        ibt_add_text.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), MainActivity.class));
            }
        });
        tx_name.setText("暱稱:name");
        return root;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        binding = null;
    }
}

  

明天要做什麼:

因為登入功能沒有做好,暫時先解決一下他們的問題

遇到的問題:

導航欄遮擋問題