android 入门学习笔记 判断网页地址 邮箱 电话号码 符合要求的加链接~

mTextView01 = (TextView)findViewById(R.id.myTextView1); 
    mEditText01 = (EditText)findViewById(R.id.myEditText1);
    
    mEditText01.setOnKeyListener(new EditText.OnKeyListener()
    {    
      @Override
      public boolean onKey(View arg0, int arg1, KeyEvent arg2)
      {
        // TODO Auto-generated method stub
        mTextView01.setText(mEditText01.getText());
        /*判断输入的类型是何种,并与系统连接*/
       Linkify.addLinks(mTextView01,Linkify.WEB_URLS|Linkify.
           EMAIL_ADDRESSES|Linkify.PHONE_NUMBERS);  
        return false;
      }
    }); 


 需要引入

import android.text.util.Linkify;

另外监听事件是用EditText的
setOnKeyListener

你可能感兴趣的:(android,email,import,电话,Numbers)