Android的helloworld程序
来源:互联网 发布:精子优化处理是什么 编辑:程序博客网 时间:2024/04/30 02:26
1.HelloWorld.java
package com.example.android.test.ligang;import android.os.Bundle;import android.annotation.SuppressLint;import android.app.Activity;import android.view.Menu;import android.view.View;//添加类import android.view.View.OnClickListener;import android.widget.Button;import android.widget.TextView;//import android.app.Activity;//import android.content.DialogInterface;//import android.content.DialogInterface.OnClickListener;//import android.os.Bundle;//import android.text.Html;//import android.view.View;//import android.widget.Button;//import android.widget.TextView;import android.widget.Toast;public class HelloWorld extends Activity{ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);//系统自动生成 setContentView(R.layout.activity_main);//系统自动生成 //添加一个按钮Button bn = (Button)findViewById(R.id.ok);//为按钮绑定一个单击事件的监听器bn.setOnClickListener(new OnClickListener(){public void onClick(View v) {// TODO Auto-generated method stub//获取UI界面中ID为R.id.show的文本框final TextView show = (TextView)findViewById(R.id.show);//改变文本框的文本内容show.setText("Hello Android~" + new java.util.Date());//返回hello和时间//提示消息框Toast toast = Toast.makeText(HelloWorld.this, "其实Android真的很容易", Toast.LENGTH_SHORT);toast.show();}}); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } }
2.res/layout/activity_main.xml 布局文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id="@+id/show" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="@string/hello_world" tools:context=".MainActivity" /> <Button android:id="@+id/ok" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:text="你好,android^O^" /></RelativeLayout>
- Android的helloworld程序
- 我的第一个android程序 HelloWorld
- 我的第一个Android程序--HelloWorld
- Android HelloWorld程序
- 一个Android程序 Helloworld
- 【Android Developer】2.Android的第一个Helloworld程序
- OpenGL的HelloWorld程序
- Struts2的HelloWorld程序
- Struts2的HelloWorld程序
- Struts2的HelloWorld程序
- django的helloworld程序
- 简单的HelloWorld程序
- mel的helloworld程序
- HightChart的helloWorld程序
- UEFI的helloworld程序
- 第一个android程序:helloworld
- 第一个android程序--helloworld
- Android第一个程序"HelloWorld"
- 爱情念想
- Xrlly.Absolute.MP3.Splitter.Converter.v3.5.0-LAXiTY
- Xrlly.Text.to.Speech.Maker.v2.2.0.READ.NFO-LAXiTY
- Xrlly.Arial.Audio.Converter.v3.0.2.READ.NFO-LAXiTY
- Xrlly.Arial.CD.Ripper.v2.2.0-LAXiTY
- Android的helloworld程序
- VIM使用技巧
- js,py,ru
- oracle网络基础
- listView.addFooterView时出现java.lang.ClassCastException:
- curl使用简介---转载
- ORA-02143: invalid STORAGE option --DSG oracle 11g 复制数据到oracle 10g
- 关于数据类型未知或者将会不断增加的解决方案
- ORA-600 [504], ..., [Transaction Branch Allocation] Error When Using XA [ID 868527.1]