2024/4/25(冲刺第三天)
所学时间:2小时
代码行数:200
博客园数:1篇
所学知识:
package com.example.kanglaojian;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
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 javax.annotation.Nullable;
public class personal_center extends Fragment {
private Button Personal_Center, Check_in_records, Medication_purchase_records, Consultation_records, Log_out;
public personal_center() {
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.activity_personal_center, container, false);
}
public void onViewCreated(@NonNull View view, @NonNull Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
Personal_Center=view.findViewById(R.id.Personal_Center);
Check_in_records=view.findViewById(R.id.Check_in_records);
Medication_purchase_records=view.findViewById(R.id.Medication_purchase_records);
Consultation_records=view.findViewById(R.id.Consultation_records);
Log_out=view.findViewById(R.id.Log_out);
Personal_Center.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(requireActivity(),personal.class);
startActivity(intent);
}
});
Check_in_records.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(requireActivity(),check_in_records.class);
startActivity(intent);
}
});
Medication_purchase_records.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(requireActivity(),medication_purchase_records.class);
startActivity(intent);
}
});
Consultation_records.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(requireActivity(),consultation_records.class);
startActivity(intent);
}
});
Log_out.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(requireActivity(),MainActivity.class);
startActivity(intent);
}
});
}
}
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
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 javax.annotation.Nullable;
public class personal_center extends Fragment {
private Button Personal_Center, Check_in_records, Medication_purchase_records, Consultation_records, Log_out;
public personal_center() {
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.activity_personal_center, container, false);
}
public void onViewCreated(@NonNull View view, @NonNull Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
Personal_Center=view.findViewById(R.id.Personal_Center);
Check_in_records=view.findViewById(R.id.Check_in_records);
Medication_purchase_records=view.findViewById(R.id.Medication_purchase_records);
Consultation_records=view.findViewById(R.id.Consultation_records);
Log_out=view.findViewById(R.id.Log_out);
Personal_Center.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(requireActivity(),personal.class);
startActivity(intent);
}
});
Check_in_records.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(requireActivity(),check_in_records.class);
startActivity(intent);
}
});
Medication_purchase_records.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(requireActivity(),medication_purchase_records.class);
startActivity(intent);
}
});
Consultation_records.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(requireActivity(),consultation_records.class);
startActivity(intent);
}
});
Log_out.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(requireActivity(),MainActivity.class);
startActivity(intent);
}
});
}
}
<?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"
tools:context=".personal_center"
android:orientation="vertical">
<Button
android:id="@+id/Personal_Center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:backgroundTint="@color/white"
android:textSize="20dp"
android:text="个人中心 >"
android:textColor="@color/black"/>
<Button
android:id="@+id/Check_in_records"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:backgroundTint="@color/white"
android:textSize="20dp"
android:text="打卡记录 >"
android:textColor="@color/black"/>
<Button
android:id="@+id/Medication_purchase_records"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:backgroundTint="@color/white"
android:textSize="20dp"
android:text="买药记录 >"
android:textColor="@color/black"/>
<Button
android:id="@+id/Consultation_records"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:backgroundTint="@color/white"
android:textSize="20dp"
android:text="问诊记录 >"
android:textColor="@color/black"/>
<Button
android:id="@+id/Log_out"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
android:backgroundTint="@color/white"
android:textSize="20dp"
android:text="退出登录"
android:textColor="@color/red"/>
</LinearLayout>
<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"
tools:context=".personal_center"
android:orientation="vertical">
<Button
android:id="@+id/Personal_Center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:backgroundTint="@color/white"
android:textSize="20dp"
android:text="个人中心 >"
android:textColor="@color/black"/>
<Button
android:id="@+id/Check_in_records"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:backgroundTint="@color/white"
android:textSize="20dp"
android:text="打卡记录 >"
android:textColor="@color/black"/>
<Button
android:id="@+id/Medication_purchase_records"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:backgroundTint="@color/white"
android:textSize="20dp"
android:text="买药记录 >"
android:textColor="@color/black"/>
<Button
android:id="@+id/Consultation_records"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:backgroundTint="@color/white"
android:textSize="20dp"
android:text="问诊记录 >"
android:textColor="@color/black"/>
<Button
android:id="@+id/Log_out"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
android:backgroundTint="@color/white"
android:textSize="20dp"
android:text="退出登录"
android:textColor="@color/red"/>
</LinearLayout>