美文网首页
ANDROID自动判断输入是电话,网址或者EMAIL的方法—-L

ANDROID自动判断输入是电话,网址或者EMAIL的方法—-L

作者: 故江 | 来源:发表于2020-02-18 16:17 被阅读0次
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".WebActivity">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="正在接收中"/>
</LinearLayout>
public class WebActivity extends AppCompatActivity {

    private TextView text;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_web);
        text = findViewById(R.id.textView);
        text.setText("https://blog.csdn.net/hellocsz/article/details/82288945");

        text.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //判断输入的类型是哪种,并与系统连接
                Linkify.addLinks(text, Linkify.WEB_URLS|
                        Linkify.EMAIL_ADDRESSES|Linkify.PHONE_NUMBERS);
            }
        });
    }
}

相关文章

网友评论

      本文标题:ANDROID自动判断输入是电话,网址或者EMAIL的方法—-L

      本文链接:https://www.haomeiwen.com/subject/gmggfhtx.html