Android工具栏的使用

90 阅读1分钟

字体大小

设置显示的值

设置字体银色

设置图标银色

用到图片添加的东西

package com.example.a3_12_1_lanqiukonzhiqi;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
public class MyViewModel extends ViewModel {
    private MutableLiveData<Integer> aTeamScore;//a号
    private MutableLiveData<Integer> bTeamScore;//b号
    private  int aBack,bBack; //记录2个数的值

    public MutableLiveData<Integer> getaTeamScore() {
        if(aTeamScore==null){
            aTeamScore=new MutableLiveData<>();
            aTeamScore.setValue(0);
        }
        return aTeamScore;
    }

    public MutableLiveData<Integer> getbTeamScore() {
        if(bTeamScore==null){
            bTeamScore=new MutableLiveData<>();
            bTeamScore.setValue(0);
        }
        return bTeamScore;
    }


    public  void aTeamAdd(int p){
        aBack=aTeamScore.getValue();
        bBack=bTeamScore.getValue();
        aTeamScore.setValue(aTeamScore.getValue()+p);

    }

    public  void bTeamAdd(int p){
        aTeamScore.setValue(bTeamScore.getValue()+p);

    }

    public  void reset(){   //用来归零
        aTeamScore.setValue(0);
        bTeamScore.setValue(0);
    }

    public void undo(){
        aTeamScore.setValue(aBack);
        bTeamScore.setValue(bBack);
    }

}