diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index 65a806c..90d5871 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -21,7 +21,7 @@
android:name=".EnrollActivity"
android:exported="false" />
diff --git a/src/main/java/com/example/liyueling_final/Expert2.java b/src/main/java/com/example/liyueling_final/Expert2.java
index 3caae8b..0f00248 100644
--- a/src/main/java/com/example/liyueling_final/Expert2.java
+++ b/src/main/java/com/example/liyueling_final/Expert2.java
@@ -6,6 +6,7 @@ import java.util.List;
public class Expert2 {
+
@SerializedName("code")
public Integer code;
@SerializedName("message")
@@ -21,15 +22,8 @@ public class Expert2 {
@SerializedName("comment")
public String comment;
@SerializedName("number")
- public NumberDTO number;
+ public String number;
@SerializedName("img")
public String img;
-
- public static class NumberDTO {
- @SerializedName("number1")
- public Integer number1;
- @SerializedName("number2")
- public Integer number2;
- }
}
}
diff --git a/src/main/java/com/example/liyueling_final/LoginMainActivity.java b/src/main/java/com/example/liyueling_final/LoginMainActivity.java
index bf7fcba..e7a49be 100644
--- a/src/main/java/com/example/liyueling_final/LoginMainActivity.java
+++ b/src/main/java/com/example/liyueling_final/LoginMainActivity.java
@@ -86,6 +86,7 @@ public class LoginMainActivity extends AppCompatActivity {
while (cursor.moveToNext()) {
if (cursor != null && cursor.getString(cursor.getColumnIndex("password")).equals(userPassword)) {
Intent intent = new Intent(LoginMainActivity.this, MainActivity.class);
+ intent.putExtra("username", phoneNumber);
startActivity(intent);
finish();
flag = false;
diff --git a/src/main/java/com/example/liyueling_final/MainActivity.java b/src/main/java/com/example/liyueling_final/MainActivity.java
index 82988f4..84499a7 100644
--- a/src/main/java/com/example/liyueling_final/MainActivity.java
+++ b/src/main/java/com/example/liyueling_final/MainActivity.java
@@ -1,5 +1,6 @@
package com.example.liyueling_final;
+import android.content.Intent;
import android.os.Bundle;
import android.view.View;
@@ -18,6 +19,14 @@ public class MainActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
+ String username = getIntent().getStringExtra("username");
+
+ Bundle bundle = new Bundle();
+ bundle.putString("username", username);
+ userFragment.setArguments(bundle);
+ studyFragment.setArguments(bundle);
+
+
getSupportFragmentManager().beginTransaction()
.add(R.id.constraintLayoutmainmajor,studyFragment)
.commit();
diff --git a/src/main/java/com/example/liyueling_final/MainexpertFragment.java b/src/main/java/com/example/liyueling_final/MainexpertFragment.java
index e1adca6..97149b7 100644
--- a/src/main/java/com/example/liyueling_final/MainexpertFragment.java
+++ b/src/main/java/com/example/liyueling_final/MainexpertFragment.java
@@ -14,6 +14,10 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
+import com.youth.banner.Banner;
+import com.youth.banner.adapter.BannerImageAdapter;
+import com.youth.banner.holder.BannerImageHolder;
+import com.youth.banner.indicator.CircleIndicator;
import java.util.ArrayList;
import java.util.List;
@@ -29,7 +33,7 @@ public class MainexpertFragment extends Fragment {
MyAdpater myAdpater;
List expert1List = new ArrayList<>();
RecyclerView recyclerView2 ;
- MyAdpater myAdpater2;
+ MyAdpater2 myAdpater2;
List expert2List = new ArrayList<>();
@Override
@@ -37,6 +41,26 @@ public class MainexpertFragment extends Fragment {
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_mainexpert, container, false);
+ super.onCreate(savedInstanceState);
+ Banner banner = view.findViewById(R.id.banner);
+ List list = new ArrayList<>();
+ list.add("https://img95.699pic.com/photo/50135/8179.jpg_wh300.jpg");
+ list.add("https://img.zcool.cn/community/010e885e01dc58a80120a8951d4d30.jpg@1280w_1l_2o_100sh.jpg");
+ list.add("https://img.zcool.cn/community/01bc575d39062ca80120695c4b71e6.jpg@2o.jpg");
+ list.add("https://img.zcool.cn/community/0176235d392960a80120695c2264b2.jpg@1280w_1l_2o_100sh.jpg");
+ banner.setAdapter(new BannerImageAdapter(list) {
+ @Override
+ public void onBindView(BannerImageHolder holder, String data, int position, int size) {
+
+
+ Glide.with(holder.itemView)
+ .load(data)
+ .into(holder.imageView);
+ }
+ });
+ banner.setIndicator(new CircleIndicator(getContext()));
+ banner.setIndicatorRadius(100);
+
Expert1Api expert1Api = RetrofitUtils.getRetrofit("https://dev.usemock.com/664ac0559e857b0cdafce629/").create(Expert1Api.class);
Expert2Api expert2Api = RetrofitUtils.getRetrofit("https://dev.usemock.com/664ac0559e857b0cdafce629/").create(Expert2Api.class);
for (int i = 1; i < 4; i++) {
@@ -63,14 +87,14 @@ public class MainexpertFragment extends Fragment {
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
for (int i = 1; i < 4; i++) {
- Call call = expert2Api.people2(i);
+ Call call2 = expert2Api.people2(i);
Log.i("123456", "onFailure: ");
- call.enqueue(new Callback() {
+ call2.enqueue(new Callback() {
@Override
public void onResponse(Call call, Response response) {
Expert2 expert2 = response.body();
- expert1List.addAll(expert2.data);
- myAdpater.notifyDataSetChanged();
+ expert2List.addAll(expert2.data);
+ myAdpater2.notifyDataSetChanged();
}
@Override
@@ -81,7 +105,7 @@ public class MainexpertFragment extends Fragment {
}
recyclerView2 = view.findViewById(R.id.recyclerview2);
- myAdpater2 = new MyAdpater();
+ myAdpater2 = new MyAdpater2();
recyclerView2.setAdapter(myAdpater2);
recyclerView2.setLayoutManager(new LinearLayoutManager(getActivity()));
return view;
@@ -98,14 +122,16 @@ public class MainexpertFragment extends Fragment {
super(itemView);
textView = itemView.findViewById(R.id.name);
- textView2 = itemView.findViewById(R.id.book);
- textView3 = itemView.findViewById(R.id.introduce);
+ textView2 = itemView.findViewById(R.id.number);
+ textView3 = itemView.findViewById(R.id.comment);
textView4 = itemView.findViewById(R.id.number);
imageView = itemView.findViewById(R.id.imageView133);
}
}
+
+
public class MyAdpater extends RecyclerView.Adapter {
//加载布局文件
@@ -136,4 +162,48 @@ public class MainexpertFragment extends Fragment {
return expert1List.size();
}
}
+
+ public class MyViewHolder2 extends RecyclerView.ViewHolder {
+ TextView textView;
+ TextView textView2;
+ TextView textView3;
+ ImageView imageView;
+ // 其他控件声明
+
+ public MyViewHolder2(@NonNull View itemView) {
+ super(itemView);
+
+ textView = itemView.findViewById(R.id.name);
+ textView2 = itemView.findViewById(R.id.comment);
+ textView3 = itemView.findViewById(R.id.number);
+ imageView = itemView.findViewById(R.id.imageView133);
+ }
+ }
+ public class MyAdpater2 extends RecyclerView.Adapter {
+
+ @NonNull
+ @Override
+ public MyViewHolder2 onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ View view = LayoutInflater.from(getActivity()).inflate(R.layout.expert2_item_layout, parent, false);
+ return new MyViewHolder2(view);
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull MyViewHolder2 holder, int position) {
+ holder.textView.setText(expert2List.get(position).name);
+ holder.textView2.setText(expert2List.get(position).comment);
+ holder.textView3.setText(expert2List.get(position).number);
+ Glide.with(getActivity())
+ .load(getResources().getIdentifier(expert2List.get(position).img, "drawable", getContext().getPackageName()))
+ .into(holder.imageView);
+ }
+
+ @Override
+ public int getItemCount() {
+ return expert2List.size();
+ }
+ }
+
+ // 第二个 ViewHolder 类
+
}
\ No newline at end of file
diff --git a/src/main/java/com/example/liyueling_final/MaingoodFragment.java b/src/main/java/com/example/liyueling_final/MaingoodFragment.java
index bee2362..f4fc05e 100644
--- a/src/main/java/com/example/liyueling_final/MaingoodFragment.java
+++ b/src/main/java/com/example/liyueling_final/MaingoodFragment.java
@@ -7,13 +7,42 @@ import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
+import com.bumptech.glide.Glide;
+import com.youth.banner.Banner;
+import com.youth.banner.adapter.BannerImageAdapter;
+import com.youth.banner.holder.BannerImageHolder;
+import com.youth.banner.indicator.CircleIndicator;
+
+import java.util.ArrayList;
+import java.util.List;
+
public class MaingoodFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_maingood, container, false);
+ super.onCreate(savedInstanceState);
+ Banner banner = view.findViewById(R.id.banner);
+ List list = new ArrayList<>();
+ list.add("https://img95.699pic.com/photo/50135/8179.jpg_wh300.jpg");
+ list.add("https://img.zcool.cn/community/010e885e01dc58a80120a8951d4d30.jpg@1280w_1l_2o_100sh.jpg");
+ list.add("https://img.zcool.cn/community/01bc575d39062ca80120695c4b71e6.jpg@2o.jpg");
+ list.add("https://img.zcool.cn/community/0176235d392960a80120695c2264b2.jpg@1280w_1l_2o_100sh.jpg");
+ banner.setAdapter(new BannerImageAdapter(list) {
+ @Override
+ public void onBindView(BannerImageHolder holder, String data, int position, int size) {
+
+
+ Glide.with(holder.itemView)
+ .load(data)
+ .into(holder.imageView);
+ }
+ });
+ banner.setIndicator(new CircleIndicator(getContext()));
+ banner.setIndicatorRadius(100);
// Inflate the layout for this fragment
- return inflater.inflate(R.layout.fragment_maingood, container, false);
+ return view;
}
}
\ No newline at end of file
diff --git a/src/main/java/com/example/liyueling_final/MainhomeFragment.java b/src/main/java/com/example/liyueling_final/MainhomeFragment.java
index 15140f3..ccf40aa 100644
--- a/src/main/java/com/example/liyueling_final/MainhomeFragment.java
+++ b/src/main/java/com/example/liyueling_final/MainhomeFragment.java
@@ -7,12 +7,41 @@ import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
+import com.bumptech.glide.Glide;
+import com.youth.banner.Banner;
+import com.youth.banner.adapter.BannerImageAdapter;
+import com.youth.banner.holder.BannerImageHolder;
+import com.youth.banner.indicator.CircleIndicator;
+
+import java.util.ArrayList;
+import java.util.List;
+
public class MainhomeFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_mainhome, container, false);
+ super.onCreate(savedInstanceState);
+ Banner banner = view.findViewById(R.id.banner);
+ List list = new ArrayList<>();
+ list.add("https://img95.699pic.com/photo/50135/8179.jpg_wh300.jpg");
+ list.add("https://img.zcool.cn/community/010e885e01dc58a80120a8951d4d30.jpg@1280w_1l_2o_100sh.jpg");
+ list.add("https://img.zcool.cn/community/01bc575d39062ca80120695c4b71e6.jpg@2o.jpg");
+ list.add("https://img.zcool.cn/community/0176235d392960a80120695c2264b2.jpg@1280w_1l_2o_100sh.jpg");
+ banner.setAdapter(new BannerImageAdapter(list) {
+ @Override
+ public void onBindView(BannerImageHolder holder, String data, int position, int size) {
+
+
+ Glide.with(holder.itemView)
+ .load(data)
+ .into(holder.imageView);
+ }
+ });
+ banner.setIndicator(new CircleIndicator(getContext()));
+ banner.setIndicatorRadius(100);
// Inflate the layout for this fragment
- return inflater.inflate(R.layout.fragment_mainhome, container, false);
+ return view;
}
}
\ No newline at end of file
diff --git a/src/main/java/com/example/liyueling_final/StudyFragment.java b/src/main/java/com/example/liyueling_final/StudyFragment.java
index ec0b0ad..580e652 100644
--- a/src/main/java/com/example/liyueling_final/StudyFragment.java
+++ b/src/main/java/com/example/liyueling_final/StudyFragment.java
@@ -5,19 +5,22 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment;
public class StudyFragment extends Fragment {
-
-
-
+ TextView textView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_study, container, false);
ConstraintLayout constraintLayout = view.findViewById(R.id.click);
+
+ String username = getArguments().getString("username");
+ textView = view.findViewById(R.id.username);
+ textView.setText(username);
constraintLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
diff --git a/src/main/java/com/example/liyueling_final/UserFragment.java b/src/main/java/com/example/liyueling_final/UserFragment.java
index 6f2237c..6e40c90 100644
--- a/src/main/java/com/example/liyueling_final/UserFragment.java
+++ b/src/main/java/com/example/liyueling_final/UserFragment.java
@@ -1,63 +1,25 @@
package com.example.liyueling_final;
+import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.TextView;
import androidx.fragment.app.Fragment;
-/**
- * A simple {@link Fragment} subclass.
- * Use the {@link UserFragment#newInstance} factory method to
- * create an instance of this fragment.
- */
+
public class UserFragment extends Fragment {
-
- // TODO: Rename parameter arguments, choose names that match
- // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
- private static final String ARG_PARAM1 = "param1";
- private static final String ARG_PARAM2 = "param2";
-
- // TODO: Rename and change types of parameters
- private String mParam1;
- private String mParam2;
-
- public UserFragment() {
- // Required empty public constructor
- }
-
- /**
- * Use this factory method to create a new instance of
- * this fragment using the provided parameters.
- *
- * @param param1 Parameter 1.
- * @param param2 Parameter 2.
- * @return A new instance of fragment UserFragment.
- */
- // TODO: Rename and change types and number of parameters
- public static UserFragment newInstance(String param1, String param2) {
- UserFragment fragment = new UserFragment();
- Bundle args = new Bundle();
- args.putString(ARG_PARAM1, param1);
- args.putString(ARG_PARAM2, param2);
- fragment.setArguments(args);
- return fragment;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- if (getArguments() != null) {
- mParam1 = getArguments().getString(ARG_PARAM1);
- mParam2 = getArguments().getString(ARG_PARAM2);
- }
- }
-
+ TextView textView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.fragment_user, container, false);
+ View view = inflater.inflate(R.layout.fragment_user, container, false);
+
+ String username = getArguments().getString("username");
+ textView = view.findViewById(R.id.username);
+ textView.setText(username);
+ return view;
}
}
\ No newline at end of file
diff --git a/src/main/java/com/example/liyueling_final/ViewAction.java b/src/main/java/com/example/liyueling_final/ViewAction.java
index 87befad..9299520 100644
--- a/src/main/java/com/example/liyueling_final/ViewAction.java
+++ b/src/main/java/com/example/liyueling_final/ViewAction.java
@@ -1,12 +1,14 @@
package com.example.liyueling_final;
import android.os.Bundle;
+import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.constraintlayout.widget.ConstraintLayout;
public class ViewAction extends AppCompatActivity {
WebView webView;
@@ -16,6 +18,14 @@ public class ViewAction extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_action); // 先设置布局
+ ConstraintLayout constraintLayout4 = findViewById(R.id.back);
+ constraintLayout4.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ finish();
+ }
+ });
+
webView = findViewById(R.id.webView); // 现在可以安全地查找视图
// 初始化 WebView 设置
diff --git a/src/main/res/layout/expert1_item_layout.xml b/src/main/res/layout/expert1_item_layout.xml
index 0d3fdc2..07607dd 100644
--- a/src/main/res/layout/expert1_item_layout.xml
+++ b/src/main/res/layout/expert1_item_layout.xml
@@ -29,16 +29,16 @@
app:layout_constraintStart_toEndOf="@+id/imageView134" />
+ app:layout_constraintStart_toStartOf="@+id/number"
+ app:layout_constraintTop_toBottomOf="@+id/number" />
-
+ app:layout_constraintTop_toTopOf="parent" />
-
+ app:layout_constraintTop_toTopOf="parent" />
-
+ app:layout_constraintTop_toTopOf="parent" />
+ app:layout_constraintTop_toBottomOf="@+id/username" />
+ app:layout_constraintTop_toBottomOf="@+id/username" />