今天做了什么:
把个人中心界面弄完了,因为其他活动界面还没做,就每个按钮功能姑且是跳转回主页面,名字和手机号是要用登录时缓存的数据
这是个人中心页面代码
<?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; } }
明天要做什么:
因为登录功能没有做好,暂时先解决一下他们的问题
遇到的问题:
导航栏遮挡问题
标签:10,root,第三天,冲刺,new,import,ibt,public,View From: https://www.cnblogs.com/chukjbgg333/p/18151478