zoukankan      html  css  js  c++  java
  • 电话拨号盘(带触摸振动反馈)

    package com.example.theold;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.net.Uri;
    import android.os.Bundle;
    import android.os.Vibrator;
    import android.provider.Contacts;
    import android.view.View;
    import android.view.Window;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.EditText;
    
    public class phoneCall extends Activity {
           
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.phonecall_layout);
    		final Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
    		final int vibrateTime = 40 ;
    		final EditText text = (EditText)findViewById(R.id.text) ;
    		Button one  = (Button)findViewById(R.id.one) ;
    		Button two  = (Button)findViewById(R.id.two) ;
    		Button three  = (Button)findViewById(R.id.three) ;
    		Button four  = (Button)findViewById(R.id.four) ;
    		Button five  = (Button)findViewById(R.id.five) ;
    		Button six  = (Button)findViewById(R.id.six) ;
    		Button seven  = (Button)findViewById(R.id.seven) ;
    		Button eight  = (Button)findViewById(R.id.eight) ;
    		Button nine  = (Button)findViewById(R.id.nine) ;
    		Button zero  = (Button)findViewById(R.id.zero) ;
    		Button xing  = (Button)findViewById(R.id.xing) ;
    		Button jing  = (Button)findViewById(R.id.jing) ;
    		Button backspace  = (Button)findViewById(R.id.backspace) ;
    		Button call  = (Button)findViewById(R.id.call) ;
    		Button people =(Button)findViewById(R.id.people) ;
    		zero.setOnClickListener(new OnClickListener() {
    			
    			@Override
    			public void onClick(View v) {
    				// TODO Auto-generated method stub
    				CharSequence temp = text.getText() ;
    				String str = temp.toString();
    				str+="0" ;
    				text.setText(str);
    				vibrator.vibrate(vibrateTime);
    				
    			}
    		});
    		
    		
          one.setOnClickListener(new OnClickListener() {
    			
    			@Override
    			public void onClick(View v) {
    				// TODO Auto-generated method stub
    				CharSequence temp = text.getText() ;
    				String str = temp.toString();
    				str+="1" ;
    				text.setText(str);
    				vibrator.vibrate(vibrateTime);
    				
    			}
    		});
          
          
          two.setOnClickListener(new OnClickListener() {
    			
    			@Override
    			public void onClick(View v) {
    				// TODO Auto-generated method stub
    				CharSequence temp = text.getText() ;
    				String str = temp.toString();
    				str+="2" ;
    				text.setText(str);
    				vibrator.vibrate(vibrateTime);
    				
    			}
    		});
          
          
          three.setOnClickListener(new OnClickListener() {
    			
    			@Override
    			public void onClick(View v) {
    				// TODO Auto-generated method stub
    				CharSequence temp = text.getText() ;
    				String str = temp.toString();
    				str+="3" ;
    				text.setText(str);
    				vibrator.vibrate(vibrateTime);
    				
    			}
    		});
          
          
          four.setOnClickListener(new OnClickListener() {
    			
    			@Override
    			public void onClick(View v) {
    				// TODO Auto-generated method stub
    				CharSequence temp = text.getText() ;
    				String str = temp.toString();
    				str+="4" ;
    				text.setText(str);
    				vibrator.vibrate(vibrateTime);
    				
    			}
    		});
          
          
          five.setOnClickListener(new OnClickListener() {
    			
    			@Override
    			public void onClick(View v) {
    				// TODO Auto-generated method stub
    				CharSequence temp = text.getText() ;
    				String str = temp.toString();
    				str+="5" ;
    				text.setText(str);
    				vibrator.vibrate(vibrateTime);
    				
    			}
    		});
          
          
          six.setOnClickListener(new OnClickListener() {
    			
    			@Override
    			public void onClick(View v) {
    				// TODO Auto-generated method stub
    				CharSequence temp = text.getText() ;
    				String str = temp.toString();
    				str+="6" ;
    				text.setText(str);
    				vibrator.vibrate(vibrateTime);
    				
    			}
    		});
          
          
          seven.setOnClickListener(new OnClickListener() {
    			
    			@Override
    			public void onClick(View v) {
    				// TODO Auto-generated method stub
    				CharSequence temp = text.getText() ;
    				String str = temp.toString();
    				str+="7" ;
    				text.setText(str);
    				vibrator.vibrate(vibrateTime);
    				
    			}
    		});
          
          eight.setOnClickListener(new OnClickListener() {
    			
    			@Override
    			public void onClick(View v) {
    				// TODO Auto-generated method stub
    				CharSequence temp = text.getText() ;
    				String str = temp.toString();
    				str+="8" ;
    				text.setText(str);
    				vibrator.vibrate(vibrateTime);
    				
    			}
    		});
          
          
          nine.setOnClickListener(new OnClickListener() {
    			
    			@Override
    			public void onClick(View v) {
    				// TODO Auto-generated method stub
    				CharSequence temp = text.getText() ;
    				String str = temp.toString();
    				str+="9" ;
    				text.setText(str);
    				vibrator.vibrate(vibrateTime);
    				
    			}
    		});
          
          
          xing.setOnClickListener(new OnClickListener() {
    			
    			@Override
    			public void onClick(View v) {
    				// TODO Auto-generated method stub
    				CharSequence temp = text.getText() ;
    				String str = temp.toString();
    				str+="*" ;
    				text.setText(str);
    				vibrator.vibrate(vibrateTime);
    				
    			}
    		});
          
          
          jing.setOnClickListener(new OnClickListener() {
    			
    			@Override
    			public void onClick(View v) {
    				// TODO Auto-generated method stub
    				CharSequence temp = text.getText() ;
    				String str = temp.toString();
    				str+="#" ;
    				text.setText(str);
    				vibrator.vibrate(vibrateTime);
    				
    			}
    		});
          
          
          
          backspace.setOnClickListener(new OnClickListener() {
    			
    			@Override
    			public void onClick(View v) {
    				// TODO Auto-generated method stub
    				CharSequence temp = text.getText() ;
    				String str = temp.toString();
    				int len = str.length() ;
    				if(len==0)
    				{
    					vibrator.vibrate(vibrateTime);
    					return ;
    				}
    				str = str.substring(0,len-1) ;
    				text.setText(str);
    				vibrator.vibrate(vibrateTime);
    				
    			}
    		});
          
          call.setOnClickListener(new OnClickListener() {
    			
    			@Override
    			public void onClick(View v) {
    				// TODO Auto-generated method stub
    				CharSequence temp = text.getText() ;
    				String str = temp.toString();
    				vibrator.vibrate(vibrateTime);
    				Intent intent = new Intent() ;
    				intent.setAction(Intent.ACTION_CALL) ;
    				intent.setData(Uri.parse("tel:"+str)) ;
    				startActivity(intent);
    				
    			}
    		});
          people.setOnClickListener(new OnClickListener() {
    		
    		@Override
    		public void onClick(View v) {
                /* Intent intent= new Intent("com.android.contacts.action.LIST_STREQUENT");   
    		    intent.setClassName("com.android.contacts","com.android.contacts.DialtactsActivity");
    		    startActivity(intent);*/
    			Intent intent = new Intent() ;
    			intent.setClass(getApplicationContext(), Photos.class) ;
    			startActivity(intent);
    			
    		}
    	});
    	}
    
    }
    
     




  • 相关阅读:
    coder的脚印
    Mysql
    MSDos
    Windows Develop
    Eclipse 使用总结
    DBA常用SQL
    SSH总结
    Unity3D协程
    yield的作用
    UGUI优化
  • 原文地址:https://www.cnblogs.com/emoji/p/4436852.html
Copyright © 2011-2022 走看看