安卓Android 按鈕案例
Android Button Example | Examples Java Code Geeks
安卓的UI中最基本設計是按鈕操作,該文圖示瞭如何用Eclipse視覺化給安卓Android專案增加按鈕。
首先建立一個Android Activity:
執行程式碼效果如下:
安卓的UI中最基本設計是按鈕操作,該文圖示瞭如何用Eclipse視覺化給安卓Android專案增加按鈕。
首先建立一個Android Activity:
完成後,在res/layout/main.xml檔案被建立:
開啟這個main.xml, Eclipse出現如下視覺化介面:
將按鈕從左邊form widgets拖到右邊介面中,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="www.javacodegeeks.com" />
</LinearLayout>
然後,回到layout頁面,建立下面java檔案:
package com.javacodegeeks.android.buttonexample; 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 MainActivity extends Activity { private Button button; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); addListenerOnButton(); } public void addListenerOnButton() { //Select a specific button to bundle it with the action you want button = (Button) findViewById(R.id.button1); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { Intent openBrowser = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.javacodegeeks.com")); startActivity(openBrowser); } }); } } <p class="indent"> |
執行程式碼效果如下:
[該貼被admin於2012-12-12 15:50修改過]
相關文章
- 安卓開發學習-按鈕控制元件安卓控制元件
- 按鈕上面的按鈕 (轉)
- Android--按鈕點選事件Android事件
- Android 點選按鈕跳轉Android
- 按鈕
- Android處理按鈕重複點選Android
- Android | 使用 AspectJ 限制按鈕快速點選Android
- Android UI控制元件系列:Button(按鈕)AndroidUI控制元件
- Android輸入框中加入清除按鈕Android
- 按鈕禁用
- Bootstrap 按鈕boot
- Android 自定義實現switch開關按鈕Android
- Android介面-標題和按鈕定製-drawableAndroid
- Android Fragment實現按鈕間的切換AndroidFragment
- Fiori Elements List Report table 裡的普通按鈕,Global 按鈕 和 Determining 按鈕
- 窗體(文字框,按鈕,單選按鈕,標籤)
- 小程式按鈕
- Flutter Button(按鈕)Flutter
- iOS 按鈕動畫iOS動畫
- 復飛按鈕
- 新增按鈕事件事件
- div按鈕CSSCSS
- UIButton - 按鈕UI
- 核取方塊和切換按鈕的7個使用案例
- android音視訊指南-響應媒體按鈕Android
- Android 自定義Switch開關按鈕的樣式Android
- 改變Android按鈕背景顏色的高效方法Android
- Android 學習筆記四:建立工具欄按鈕Android筆記
- 安卓開發之封裝顯示倒數計時按鈕控制元件安卓封裝控制元件
- VBA命令按鈕操作
- vue 封裝按鈕Vue封裝
- HTML input image按鈕HTML
- HTML input image 按鈕HTML
- HTML input button按鈕HTML
- HTML input button 按鈕HTML
- 瞭解下Foundation 按鈕
- HTML input submit 按鈕HTMLMIT
- iOS動畫-按鈕動畫iOS動畫