• 钢镚儿开发第三、第四天


    package com.example.myapplicationgb;
    
    import android.app.AlarmManager;
    import android.app.PendingIntent;
    import android.content.Intent;
    import android.os.Bundle;
    import android.os.SystemClock;
    import android.view.View;
    import android.widget.ImageButton;
    
    import androidx.appcompat.app.AppCompatActivity;
    import androidx.fragment.app.Fragment;
    import androidx.fragment.app.FragmentManager;
    import androidx.fragment.app.FragmentTransaction;
    
    
    public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    
        private static final String TAG = "MainActivity";
        private FragmentTransaction transaction;
        private FragmentManager manager;
        private ImageButton tabmingxi;
        private ImageButton tabadd;
        private ImageButton tabjizhang;
        private ImageButton tabUser;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
    
    
    
                    Intent intent = new Intent(this, AutoReceiver.class);
    
                    intent.setAction("VIDEO_TIMER");
    
                    // PendingIntent这个类用于处理即将发生的事情
    
                    PendingIntent sender = PendingIntent.getBroadcast(this, 0, intent, 0);
    
                    AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
    
                    // AlarmManager.ELAPSED_REALTIME_WAKEUP表示闹钟在睡眠状态下会唤醒系统并执行提示功能,该状态下闹钟使用相对时间
    
                    // SystemClock.elapsedRealtime()表示手机开始到现在经过的时间
    
                    am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
    
                            SystemClock.elapsedRealtime(), 10 * 1000, sender);
    
    
            //初始化控件
            initView();
    
            manager = getSupportFragmentManager();
            transaction = manager.beginTransaction();
            //将主页添加到第一个fragment中,即默认fragment
            Fragment fragment_index = new FirstFragment();
            transaction.add(R.id.fragment_container,fragment_index);
            transaction.commit();
        }
    
    
    
    
        private void initView() {
            tabmingxi = (ImageButton)this.findViewById(R.id.txt_mingxi);
            tabadd = (ImageButton)this.findViewById(R.id.txt_add);
            tabjizhang= (ImageButton)this.findViewById(R.id.txt_jizhang1);
            tabUser=this.findViewById(R.id.txt_user);
    
            tabmingxi.setOnClickListener(this);
            tabadd.setOnClickListener(this);
            tabjizhang.setOnClickListener(this);
            tabUser.setOnClickListener(this);
        }
    
        @Override
        public void onClick(View v) {
            transaction = manager.beginTransaction();
            resetImgs();
            switch (v.getId()){
                //通过switch判断用哪个fragment替换当前的fragment
                case R.id.txt_mingxi:
                    Fragment firstfragment = new FirstFragment();
                    transaction.replace(R.id.fragment_container,firstfragment);
                    tabmingxi.setImageResource(R.mipmap.mingxi1);
                    //tabmingxi.setImageResource(R.mipmap.mingxi);
                    break;
                case R.id.txt_add:
                    Fragment erfragment = new erFragment();
                    transaction.replace(R.id.fragment_container,erfragment);
                    tabadd.setImageResource(R.mipmap.tianjia1);
                    break;
                case R.id.txt_jizhang1:
                    Fragment sanfragment = new sanFragment();
                    transaction.replace(R.id.fragment_container,sanfragment);
                    tabjizhang.setImageResource(R.mipmap.a_tubiao);
                    break;
                case R.id.txt_user:
                    Fragment sifragment = new siFragment();
                    transaction.replace(R.id.fragment_container,sifragment);
                    tabUser.setImageResource(R.mipmap.women1);
                    break;
            }
            transaction.commit();
        }
        private void resetImgs() {
            tabmingxi.setImageResource(R.mipmap.mingxi);
            tabadd.setImageResource(R.mipmap.tianjia);
            tabjizhang.setImageResource(R.mipmap.a_tubiao);
            tabUser.setImageResource(R.mipmap.women);
        }
    }
    View Code

    这两天是周六日,主要还是进行我的界面的编写,现在我的界面有了雏形,也可以在手机上面进行运行;

    但是非常的丑陋,还需要我进行改善和完善;这两天大部分的时间都在编写安卓,参考网上人家的界面,发现自己的审美还有待提升;

    接下来的时间是要完善界面和帮助我的队友进行他们所负责的那部分内容;

     

  • 相关阅读:
    小程序样式表不支持级联选择器
    小程序为什么脚本内不能使用window等对象
    微信小程序怎么获取用户输入
    php中不借助IDE快速定位行数或者方法定义的文件和位置
    百度Ueditor编辑器取消多图上传对话框中的图片搜索
    阿里云ECS购买优惠码
    DEDE 5.7中各函数所在的文件和位置
    自定义的parse_url逆向函数http_build_url,将数组转为url字符串
    PHPMailer fe v4.11 For Thinkphp 3.2
    javascript使用技巧总结,不断更新...
  • 原文地址:https://www.cnblogs.com/1234yyf/p/12731299.html
Copyright © 2020-2023  润新知