zoukankan      html  css  js  c++  java
  • 记账本开发5

    public class Add extends AppCompatActivity 
    {
    private EditText time; @Override protected void onCreate(Bundle savedInstanceState)
       {
    super.onCreate(savedInstanceState); setContentView(R.layout.activity_add); time = findViewById(R.id.time); time.seta(new View.OnTouchListener()
         { @Override
    public boolean onTouch(View v, MotionEvent m)
           {
    if (m.getAction() == MotionEvent.ACTION_DOWN)
              { show();
    return true; } return false; } }); time.setb(new View.OnFocusChangeListener()
         { @Override
    public void onFocusChange(View v, boolean f)
           {
    if (f) {show();}} }); } protected void show()
    { Calendar cal
    =Calendar.getInstance(); DatePickerDialog dataPickerDialog=new DatePickerDialog(AddActivity.this, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) { AddActivity.this.time.setText(year+"-"+(month+1)+"-"+dayOfMonth); } },cal.get(Calendar.YEAR),cal.get(Calendar.MONTH),cal.get(Calendar.DAY_OF_MONTH)); dataPickerDialog.show(); }

    今天根据博客、CSDN、百度等修改了时间功能。

  • 相关阅读:
    二维码生成代码
    部署javaweb项目到阿里云ecs(centos7)
    mysql基础知识
    IDEA快捷键快速补齐类和对象名
    Redis和elasticsearch
    在asp.net 项目的bin目录中使用子目录
    MVC项目引用备注
    OAuth相关备注
    手动安装windows的磁盘清理工具
    在CentOS上安装 MongoDB
  • 原文地址:https://www.cnblogs.com/hfy717/p/14443500.html
Copyright © 2011-2022 走看看