首页 > 其他分享 >每日总结 2.28

每日总结 2.28

时间:2023-02-28 21:58:00浏览次数:33  
标签:总结 fragment 每日 2.28 new import android public view

今天学习python的基础语法数据类型的学习,学习了数组的计算和地址查找。

课后回到宿舍学习了 java编写app的逻辑代码。

package com.example.xx.frg_recod;

import android.inputmethodservice.KeyboardView;
import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.text.style.TypefaceSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.xx.R;
import com.example.xx.db.DBManager;
import com.example.xx.db.TypeBean;
import com.example.xx.util.KeyBordUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link OutcomeFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class OutcomeFragment extends Fragment {

    KeyboardView keyboardView;
    EditText editText;
    ImageView typeiv;
    TextView typeTv,beizhuTv,timeTv;
    GridView typegv;
    List<TypeBean> typeList;
    TypeBaseAdapter typeBaseAdapter;

    // 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 OutcomeFragment() {
        // 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 OutcomeFragment.
     */
    // TODO: Rename and change types and number of parameters
    public static OutcomeFragment newInstance(String param1, String param2) {
        OutcomeFragment fragment = new OutcomeFragment();
        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);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view= inflater.inflate(R.layout.fragment_outcome, container, false);
        initView(view);
loadDataToGv();
setGVListener();
        return view;
    }

    private void setGVListener() {
        typegv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                typeBaseAdapter.selectpos=i;
                typeBaseAdapter.notifyDataSetChanged();
                TypeBean typeBean=typeList.get(i);
                String typename=typeBean.getTypename();
                typeTv.setText(typename);

                int simageid=typeBean.getSimageid();
                typeiv.setImageResource(simageid);
            }
        });
    }

    private void loadDataToGv() {
typeList=new ArrayList<>();
        TypeBaseAdapter typeBaseAdapter = new TypeBaseAdapter(getContext(), typeList);
         typegv.setAdapter(typeBaseAdapter);
        //获取数据库数据源
        List<TypeBean> outlist=DBManager.getTypelist(0);
        typeList.addAll(outlist);
        typeBaseAdapter.notifyDataSetChanged();
    }

    private void initView(View view) {
        keyboardView=view.findViewById(R.id.frag_record_keybord);
        editText=view.findViewById(R.id.frag_record_et_money);
        typeiv=view.findViewById(R.id.frag_record_iv);
        typegv=view.findViewById(R.id.frag_record_gv);
        typeTv=view.findViewById(R.id.frag_record_tv_type);
        beizhuTv=view.findViewById(R.id.frag_record_tv_beizhu);
        timeTv=view.findViewById((R.id.frag_record_tv_time));
        KeyBordUtil bordUtil=new KeyBordUtil(keyboardView,editText);
        bordUtil.showKeyboard();
        //设置接口,监听确定按钮被点击
        bordUtil.setOnEnsureListener(new KeyBordUtil.onEnsureListener() {
            @Override
            public void onEnsure() {
                //点击了确定按钮
                //获取记录的信息保存到数据库
                //返回上一级

            }
        });
    }
}
package com.example.xx.frg_recod;

import android.content.Context;
import android.icu.text.Transliterator;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.textclassifier.ConversationAction;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.ContentView;

import com.example.xx.R;
import com.example.xx.db.TypeBean;

import java.util.List;

public class TypeBaseAdapter extends BaseAdapter {
    Context context;
    List<TypeBean> mDatas;
    int selectpos= 0;//选中位置

    public TypeBaseAdapter(Context context, List<TypeBean> mDatas) {
        this.context = context;
        this.mDatas = mDatas;
    }

    @Override
    public int getCount() {
        return mDatas.size();
    }

    @Override
    public Object getItem(int i) {
        return mDatas.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view= LayoutInflater.from(context).inflate(R.layout.item_recordfrag_gv,viewGroup,false);
        //查找布局控件
        ImageView imageView=view.findViewById(R.id.item_recordfrag_iv);
        TextView textView=view.findViewById(R.id.item_recordfrag_tv);
       TypeBean typeBean= mDatas.get(i);
       textView.setText(typeBean.getTypename());
        if (selectpos==i) {
           imageView.setImageResource(typeBean.getSimageid());
        }else{
            imageView.setImageResource(typeBean.getImageid());
        }
        return view;
    }
}

 

标签:总结,fragment,每日,2.28,new,import,android,public,view
From: https://www.cnblogs.com/syhxx/p/17166173.html

相关文章

  • 2/28每日总结
    今天上学习了数据库原理和英语准备四级,但下午发烧严重就请了半天假,晚上退烧之后学习了Android的布局的代码:<?xmlversion="1.0"encoding="utf-8"?><LinearLayoutxmln......
  • 2.28每日总结——安卓
       今天,简单了解了一下线性布局,还学习了一下昨天上课的内容(最长英语链接龙),简单的实现了几个单词的写入与输出。还没法实现《飘》的接龙。安卓这块还没怎么学,接下来......
  • 代码随想录训练营day 3|59.螺旋矩阵II 加 数组总结篇
    59.螺旋矩阵II题目链接:59.螺旋矩阵II题目描述:给定一个正整数n,生成一个包含1到n^2所有元素,且元素按顺时针顺序螺旋排列的正方形矩阵。示例:输入:3输出:[[1,......
  • 每日2023/2/28
               <?xmlversion="1.0"encoding="utf-8"?><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="match......
  • LeetCode算法训练-回溯总结
    欢迎关注个人公众号:爱喝可可牛奶LeetCode算法训练-回溯总结适用问题组合问题:N个数里面按一定规则找出k个数的集合排列问题:N个数按一定规则全排列,有几种排列方式切割问......
  • 2023.2.28Android开发
    今天早上学习了数据库原理,下午学习了Python程序设计Android开发的设置视图的对齐方式设置视图的对齐方式有两种途径:采用layout_gravity属性,它指定了当前视图相对于上级视......
  • LeetCode算法训练-回溯总结
    欢迎关注个人公众号:爱喝可可牛奶LeetCode算法训练-回溯总结适用问题组合问题:N个数里面按一定规则找出k个数的集合排列问题:N个数按一定规则全排列,有几种排列方式切割......
  • 2023.2.28每日总结
    package课堂练习01;importjava.applet.Applet;importjava.io.BufferedReader;importjava.io.File;importjava.io.FileReader;importjava.io.FileWriter;importjava......
  • 字符串中的slice(),substr(),substring()三种提取字符串的方法总结
    1、slice()slice()方法可提取字符串的某个部分,并以新的字符串返回被提取的部分。语法:str.slice(start,end),截取str从start到end的所有字符(包含起始位置,不包含结束位置)说明:st......
  • js易错问题总结系列
    整理遇到的掌握的不是特别好的问题,方便以后重点学习一、JavaScript的三种消息框alert,confirm,prompt1.alert是弹出警告框,在文本里面加入\n就可以换行。2.confirm弹出确认框......