android实现按钮跳转到指定网页
res/layout:
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button6"/>
app/java/
MainActivity.java
package com.ouyang.android.myapplication;
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;
import java.net.URL;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ratioline);
Button btn6=(Button)findViewById(R.id.button6);
btn6.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
Uri uri= Uri.parse("http://m.hbxfwyy.com");
Intent intent=new Intent(Intent.ACTION_VIEW,uri);
startActivity(intent);
}
});
}
}