zoukankan      html  css  js  c++  java
  • 每日日报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的开发

  • 相关阅读:
    Js 之判断某月有几天
    Java 之c3p0连接池对实体 "useSSL" 的引用必须以 ';' 分隔符结尾
    SQL真题实战(大厂真题)——来自牛客题霸
    公共api
    Windows下搭建redis 哨兵环境
    hibernate查询不到关联对象列表fetchType的选择
    「IOI2021」Dungeons
    「Gym103261H」Greedy Algorithm
    「牛客」牛半仙的妹子序列
    「UOJ 632」挑战最大团
  • 原文地址:https://www.cnblogs.com/leiyu1905/p/14909573.html
Copyright © 2011-2022 走看看