Android Studio 源码分析

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);
}
});
}




}
posted @ 2016-12-11 13:47  清风翠竹茶飘香  阅读(339)  评论(0编辑  收藏  举报