android学习日记——hello word
来源:互联网 发布:教育软件排名 编辑:程序博客网 时间:2024/06/04 18:13
目录介绍:
gen:R.java这个文件里面的内容是自动生成的
assets:放置任何与项目有关的文件
res:放在res文件夹中的文件会在R.java中生成一个对应ID,
res/drawable用来放置图片
res/layout放置布局文件,一个activity对应一个布局文件,
res/values应用程序中所应用到一些值,<string name="app_name">hello word</string>它以一种key value方式存储,并且第一个都会在R.java中生成一个ID
AndroidManifest.xml整个应用程序的相关配置,
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.activityo2"//应用程序包名
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher" //应用程序的图标,表示引用的是drawable下的ic_launcher这张图片
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"-------------------这个activity的类名
android:label="@string/title_activity_main" >
<intent-filter>--------------------先启动这个activity
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".OtherActivity"
android:label="@string/other"></activity>
</application>
</manifest>
------------------------------------------------------------------------------------------------------------
布局文件:
<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/myTextView" -------为创建的控件起个ID,它也会在R.java中生成对应的ID,然后我们在activity中可以用findViewById(R.id.myTextView)来得到这个控件。
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/myButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</RelativeLayout>
布局的方式开始最好采用LinearLayout布局
<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/but"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/butvalue"/>
</LinearLayout>
-----------------------------------------activity--------------------------------------------
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity04);
Button button=(Button) findViewById(R.id.but);------------通过id得到Button对象
button.setText("按钮");
}
- android学习日记——hello word
- Android学习笔记——HELLO WORD
- Android——Hello Word
- Python学习——Pycharm“Hello Word”
- C win32学习1—hello word
- android学习日记(say hello to android)
- hibernate学习之路——hello word
- Android基础之——第一个项目Hello word!
- java——hello word
- springmvc学习 hello word
- [懒人日记3]驱动程序开发---Hello Word!
- Android Hello word
- android的Hello word
- Unity学习日记-hello world
- android学习日记——Activity生命周期
- android学习日记——PreferenceActivity详解
- Android学习日记——安全
- Android学习日记——INTENT
- 如何写一本计算机前端设计方面的书籍
- java并发库之Executors常用的创建ExecutorService的几个方法说明
- Cryptographic Message Syntax (CMS)
- javascript 函数,BOM
- 补银行问题
- android学习日记——hello word
- 当前多数杀软主防存在的缺陷
- MFC中编辑框的显示与隐藏
- Notification案例- 多个任务单线程下载共用一个notification显示进度
- mysql数据库中的索引有那些、有什么用?
- LSI设计(1)一般介绍(待上载)
- ASP.NET 动态创建TextBox 以及取值问题
- ExecutorService常用方法和newFixedThreadPool创建固定大小的线程池
- windows下如何安装java6.0