• 事件(4)


    时间事件监听器:OnTimeChangedListener 

      tp.setOnTimeChangedListener(new OnTimeChangedListener() {

        @Override
        public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
          String str=hourOfDay+":"+minute;
        }
      });

     1 package com.hh;
     2 
     3 import android.app.Activity;
     4 import android.os.Bundle;
     5 import android.widget.Button;
     6 import android.widget.EditText;
     7 import android.widget.RadioGroup;
     8 import android.widget.Spinner;
     9 import android.widget.TextView;
    10 import android.widget.TimePicker;
    11 import android.widget.TimePicker.OnTimeChangedListener;
    12 
    13 public class Click extends Activity{
    14     private TextView tv;        //定义信息显示组件
    15     private TimePicker tp;
    16     
    17     protected void onCreate(Bundle savedInstanceState) {
    18         super.onCreate(savedInstanceState);
    19         setContentView(R.layout.event);
    20     
    21         tv=(TextView)findViewById(R.id.tve1);            //取得文本显示组件
    22     
    23         tp=(TimePicker) findViewById(R.id.tp1);
    24         tp.setOnTimeChangedListener(new OnTimeChangedListener() {
    25             
    26             @Override
    27             public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
    28                 String str=hourOfDay+":"+minute;
    29             }
    30         });
    31 }
    32         
    代码示例
     1 <TextView
     2           android:id="@+id/tve1"
     3         android:layout_width="fill_parent" 
     4         android:layout_height="wrap_content" 
     5            android:background="#FF0000"
     6       />
     7        <TimePicker
     8                android:id="@+id/tp1"
     9             android:layout_width="fill_parent" 
    10             android:layout_height="wrap_content"
    11        />
    xml配置文件

  • 相关阅读:
    Beans
    HDU 1175 连连看
    HDU 1241 Oil Deposits dfs && bfs
    HDU1312:Red and Black
    背包问题
    canvas 和 svg
    前端性能优化---DOM操作
    四种常见的 POST 提交数据方式
    [转]浏览器缓存详解: expires, cache-control, last-modified, etag详细说明
    URL和URI
  • 原文地址:https://www.cnblogs.com/yang82/p/6971815.html
Copyright © 2020-2023  润新知