當前位置:首頁 » 安卓系統 » android案例源碼

android案例源碼

發布時間: 2024-12-09 00:58:01

⑴ 求一簡單ANDROID源碼

main.xml
<?xml version="1.0" encoding="utf-8"?>讓猛
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText android:id="@+id/edit" android:layout_width="200dp" android:layout_height="wrap_content"></EditText>
<Button android:id="@+id/bt" android:text="click" android:layout_width="wrap_content" android:layout_height="wrap_content">猜滑皮<穗差/Button>
<TextView android:id="@+id/tv" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
</LinearLayout>

test.java:
package com.android.test;

import java.text.DecimalFormat;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class test extends Activity {
/** Called when the activity is first created. */
TextView tv;
Button bt;
EditText edit;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView) findViewById(R.id.tv);
bt = (Button) findViewById(R.id.bt);
edit = (EditText) findViewById(R.id.edit);

bt.setOnClickListener(new OnClickListener(){

public void onClick(View v) {
// TODO Auto-generated method stub
String strEdit = edit.getText().toString();
float input = Float.parseFloat(strEdit);
Float output = input / 3;
DecimalFormat df = new DecimalFormat("0.##");

tv.setText(df.format(output));
}});

}
}

你試試哈

熱點內容
安卓軟體為什麼經常自啟動 發布:2025-05-14 04:38:17 瀏覽:158
譚浩強c語言第三版課後答案 發布:2025-05-14 04:37:31 瀏覽:59
san存儲和nas存儲 發布:2025-05-14 04:34:44 瀏覽:152
幽靈戰士3什麼配置 發布:2025-05-14 04:33:53 瀏覽:114
安卓的虛擬機哪個好用 發布:2025-05-14 04:32:34 瀏覽:871
宿遷存儲式化工設備 發布:2025-05-14 04:32:33 瀏覽:54
s7200編程s7200 發布:2025-05-14 04:28:32 瀏覽:413
安卓定製版蘋果手機是什麼意思 發布:2025-05-14 04:26:27 瀏覽:379
如何搭建php環境虛擬伺服器免費 發布:2025-05-14 04:25:37 瀏覽:103
相冊加密怎麼看 發布:2025-05-14 04:24:53 瀏覽:573