美文网首页
抽取方法

抽取方法

作者: pengtuanyuan | 来源:发表于2016-10-18 22:26 被阅读0次
    
    package com.example.pengtuanyuan.openweb;
    
    import android.content.Intent;
    import android.net.Uri;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            final Button button=(Button)findViewById(R.id.button1);
            button.setOnClickListener(new MyOnclickListener());
        }
    
        class MyOnclickListener implements View.OnClickListener{
            @Override
            public void onClick(View view) {
                openweb();
    
            }
        }
    
        private void openweb() {
            Intent intent=new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("https://www.hao123.com"));
            startActivity(intent);
        }
    }
    -----------------------------------------------
    
    package com.example.pengtuanyuan.openweb;
    
    import android.content.Intent;
    import android.net.Uri;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            final Button button=(Button)findViewById(R.id.button1);
            button.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    String number= button.getText().toString().trim();
    
                    Intent intent=new Intent();
                    intent.setAction(Intent.ACTION_VIEW);
                    intent.setData(Uri.parse("https://www.hao123.com"));
                    startActivity(intent);
    
                }
            });
        }
    }
    
    

    相关文章

      网友评论

          本文标题:抽取方法

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