冲刺7

1.写完了安卓的功能。

2.安卓有些繁琐,xml,Java代码,布局。都得需要设置相应的东西。

3.对安卓代码进行改进。

4.

package com.example.medicalretrieval;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.medicalretrieval.pojo.User;

public class HomeFragment extends Fragment implements View.OnClickListener {


    private View view;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        view = inflater.inflate(R.layout.fragment_home, container, false);
        ImageView avatar = view.findViewById(R.id.userHeadPicture);
        User user = (User) MyApplication.getInstance().application.get("user");
        assert user != null;
        String avatarUrl = user.getAvatar();

        // Use Glide to load image
        Glide.with(this)
                .load(avatarUrl)
                .error(R.drawable.default_avatar_man)
                .placeholder(R.drawable.default_avatar_man)
                .into(avatar);
        TextView userName = view.findViewById(R.id.userName);
        userName.setText(user.getAccount());

        TextView browsingHistory = view.findViewById(R.id.BrowsingHistory);
        browsingHistory.setOnClickListener(this);
        TextView downloadHistory = view.findViewById(R.id.downloadHistory);
        downloadHistory.setOnClickListener(this);
        TextView uploadDocument = view.findViewById(R.id.uploadDocument);
        uploadDocument.setOnClickListener(this);
        TextView addDic = view.findViewById(R.id.addDic);
        addDic.setOnClickListener(this);
        TextView aboutTheSoftware = view.findViewById(R.id.aboutTheSoftware);
        aboutTheSoftware.setOnClickListener(this);
        return view;
    }

    @Override
    public void onClick(View v) {
        Intent intent = null;
        switch (v.getId()){
            case R.id.BrowsingHistory://浏览历史
                intent = new Intent(view.getContext(),BrowsingHistoryActivity.class);
                startActivity(intent);
                break;
            case R.id.downloadHistory://下载历史
                intent = new Intent(view.getContext(),DownloadHistoryActivity.class);
                startActivity(intent);
                break;
            case R.id.uploadDocument://上传历史
                intent = new Intent(view.getContext(),UploadDocumentActivity.class);
                startActivity(intent);
                break;
            case R.id.addDic://添加词典
                intent = new Intent(view.getContext(),AddDicActivity.class);
                startActivity(intent);
                break;
            case R.id.aboutTheSoftware://关于本软件
                intent = new Intent(view.getContext(),AboutTheSoftwareActivity.class);
                startActivity(intent);
                break;
        }
    }
}

 

posted @ 2023-04-21 23:38  啦啦啦one  阅读(22)  评论(0)    收藏  举报