main.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button - Go to 百度" />

</LinearLayout>

java

package com.cjp.buttondemo;


import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Button;
import android.view.View;
import android.view.View.OnClickListener;

public class ButtonDemo extends Activity {

Button button;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

addListenerOnButton();

}

public void addListenerOnButton() {

button = (Button) findViewById(R.id.button1);

button.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {

Intent browserIntent =
new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.baidu.com"));
startActivity(browserIntent);

}

});

}

}

Android Button example_第1张图片

Android Button example_第2张图片

更多相关文章

  1. Android UI技巧(一)——Android中伸缩自如的9patch图片切法,没有美
  2. 关于android 4.4以上版本从相册选取图片加载不了图片的问题
  3. Android中 加载一张大图片Caused by: java.lang.OutOfMemoryErro
  4. Android 异步获取网络图片并处理图片Out Of Memory 内存溢出问题
  5. Android图片缩放效果代码
  6. Android 与H5交互心得(Base64图片)
  7. Android 调用系统的分享[完美实现同时分享图片和文字]
  8. Android学习札记51:在TextView显示插入的图片
  9. DataBinding赋值本地图片src

随机推荐

  1. LinearLayout中gravity和layout_gravity
  2. Android应用程序基础
  3. Android(安卓)二级列表
  4. Android CTS 测试总结【转】
  5. Android之 UI主线程
  6. Android 在界面中显示以及输入文本信息 T
  7. android ListView控件 去上下滑动阴影 选
  8. android udp通信
  9. 【android】关于退出时关闭“后台”显示
  10. Ubuntu 系统上编译Android 系统