Files
android-learn-app/app/src/main/java/top/iletter/lvnote/FragmentProfile.java
DelLevin-Home ba4aec0e08 1111
2026-02-09 22:05:05 +08:00

38 lines
1.2 KiB
Java

package top.iletter.lvnote;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
public class FragmentProfile extends Fragment {
public FragmentProfile() {
// Required empty public constructor
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_profile, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// 安全地操作 View
TextView movieCount = view.findViewById(R.id.tv_movie_count);
TextView bookCount = view.findViewById(R.id.tv_book_count);
if (movieCount != null) movieCount.setText("14");
if (bookCount != null) bookCount.setText("18");
}
}