• 每日日报2021.3.17


    今天完成内容:

    1.学习android

    package com.example.test;

     
    import android.app.Activity;
    import android.app.ActionBar;
    import android.app.Fragment;
    import android.content.Intent;
    import android.os.Bundle;
    import android.os.Handler;
    import android.view.Gravity;
    import android.view.LayoutInflater;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.view.ViewGroup;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.ImageView;
    import android.widget.LinearLayout;
    import android.widget.TextView;
    import android.widget.Toast;
    import android.os.Build;
     
    public class MainActivity extends Activity implements OnClickListener {
      Handler handler = new Handler();
     
      @Override
      public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
     
        findViewById(R.id.btnSimpleToast).setOnClickListener(this);
        findViewById(R.id.btnSimpleToastWithCustomPosition).setOnClickListener(
            this);
        findViewById(R.id.btnSimpleToastWithImage).setOnClickListener(this);
        findViewById(R.id.btnCustomToast).setOnClickListener(this);
        findViewById(R.id.btnRunToastFromOtherThread).setOnClickListener(this);
     
      }
     
      public void showToast() {
        handler.post(new Runnable() {
     
          @Override
          public void run() {
            Toast.makeText(getApplicationContext(), "我来自其他线程!",
                Toast.LENGTH_SHORT).show();
     
          }
        });
      }
     
      @Override
      public void onClick(View v) {
        Toast toast = null;
        switch (v.getId()) {
        case R.id.btnSimpleToast:
          Toast.makeText(getApplicationContext(), "默认Toast样式",
              Toast.LENGTH_SHORT).show();
          break;
        case R.id.btnSimpleToastWithCustomPosition:
          toast = Toast.makeText(getApplicationContext(), "自定义位置Toast",
              Toast.LENGTH_LONG);
          toast.setGravity(Gravity.CENTER, 0, 0);
          toast.show();
          break;
        case R.id.btnSimpleToastWithImage:
          toast = Toast.makeText(getApplicationContext(), "带图片的Toast",
              Toast.LENGTH_LONG);
          toast.setGravity(Gravity.CENTER, 0, 0);
          LinearLayout toastView = (LinearLayout) toast.getView();
          ImageView imageCodeProject = new ImageView(getApplicationContext());
          imageCodeProject.setImageResource(R.drawable.ic_launcher);
          toastView.addView(imageCodeProject, 0);
          toast.show();
          break;
        case R.id.btnCustomToast:
          LayoutInflater inflater = getLayoutInflater();
          View layout = inflater.inflate(R.layout.custom,
              (ViewGroup) findViewById(R.id.llToast));
          ImageView image = (ImageView) layout
              .findViewById(R.id.tvImageToast);
          image.setImageResource(R.drawable.ic_launcher);
          TextView title = (TextView) layout.findViewById(R.id.tvTitleToast);
          title.setText("Attention");
          TextView text = (TextView) layout.findViewById(R.id.tvTextToast);
          text.setText("完全自定义Toast");
          toast = new Toast(getApplicationContext());
          toast.setGravity(Gravity.RIGHT | Gravity.TOP, 12, 40);
          toast.setDuration(Toast.LENGTH_LONG);
          toast.setView(layout);
          toast.show();
          break;
        case R.id.btnRunToastFromOtherThread:
          new Thread(new Runnable() {
            public void run() {
              showToast();
            }
          }).start();
          break;
     
        }
     
      }
     
    }

    2.看视频

    遇到问题:

    明日目标:

    学习Android studio的开发

  • 相关阅读:
    C++入门经典-例3.4-根据成绩划分等级
    C++入门经典-例3.3-if-else语句的奇偶性判别
    C++入门经典-例3.2-根据分数判断是否优秀
    C++入门经典-例3.1-判断输入的数字是否为奇数
    C++入门经典-例2.17强制类型转换
    C++入门经典-例2.16-隐式类型转换
    C++入门经典-例2.15-逗号表达式的应用
    C++入门经典-例2.14-使用移位运算
    C++入门经典-例2.13-左移运算
    Spring之Bean管理------注解方式
  • 原文地址:https://www.cnblogs.com/leiyu1905/p/14909573.html
Copyright © 2020-2023  润新知