再此感谢mars 老师的帮助。 1、AndroidManifest.xml=> package ="com.example.hello" <activity android:name="com.example.hello.MainActivity" // 也可以用.MainActivity (.+package刚好) android:label="@string/app_name" > <intent-filter> //有这个表示第一个运行时就用这个activity . <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> 2、layout->main.xml -> <LinearLayout /*后面表示命名空间*/ xmlns:android="http://schemas.android.com/apk/res/android" //LinearLayout 是线性布局,从左到右,从上到下等。 android:layout_width="fill_parent" //在宽度上把父控件填满。 android:layout_height="fill_parent" //高度同样填满 android:orientation="vertical"> // 表示垂直的,从上到下的。 <Button android:layout_width="fill_parent" //声明在linearlayout ,所以父控件是它 android:layout_height="wrap_content" //高度正好把内容包起来就好。 android:text="传递 string 参数给c" android:id="@+id/btn2" /> 3、gen 下面有R.java 都定义res里面的内容。 4、setContentView(R.layout.main); //java 文件对应的哪一个xml文件。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。