免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1905 | 回复: 2
打印 上一主题 下一主题

请教一个入门级别的问题: [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-06-19 00:29 |只看该作者 |倒序浏览
本帖最后由 kingink1983 于 2010-06-19 00:31 编辑

在参照android docs学习的过程,发现/tutorials/hello-world.html界面下的【Upgrade the UI to an XML Layout】节的例子在前面的基础上无法编过
1 In the Eclipse Package Explorer, expand the /res/layout/ folder and open main.xml (once opened, you might need to click the "main.xml" tab at the bottom of the window to see the XML source). Replace the contents with the following XML:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <TextView xmlns:android="http://schemas.android.com/apk/res/android"
  3.   android:id="@id+/textview"
  4.   android:layout_width="fill_parent"
  5.   android:layout_height="fill_parent"
  6.   android:text="@string/hello"/>
复制代码


Save the file.
2.# Inside the res/values/ folder, open strings.xml. This is where you should save all default text strings for your user interface. If you're using Eclipse, then ADT will have started you with two strings, hello and app_name. Revise hello to something else. Perhaps "Hello, Android! I am a string resource!" The entire file should now look like this:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <resources>
  3.     <string name="hello">Hello, Android! I am a string resource!</string>
  4.     <string name="app_name">Hello, Android</string>
  5. </resources>
复制代码

3 Now open and modify your HelloAndroid class use the XML layout. Edit the file to look like this:

  1. package com.example.helloandroid;

  2. import android.app.Activity;
  3. import android.os.Bundle;

  4. public class HelloAndroid extends Activity {
  5.     /** Called when the activity is first created. */
  6.     @Override
  7.     public void onCreate(Bundle savedInstanceState) {
  8.         super.onCreate(savedInstanceState);
  9.         setContentView(R.layout.main);
  10.     }
  11. }
复制代码


仅仅是更新里textview的调用方式,在工程中,src和res的文件夹中均显示错误,无法编译,
教程中尚无特别的提示,还望大家给予指点。谢谢。

论坛徽章:
0
2 [报告]
发表于 2010-06-19 13:49 |只看该作者
好好看看错误提示吧,我不做应用。

论坛徽章:
59
2015七夕节徽章
日期:2015-08-24 11:17:25ChinaUnix专家徽章
日期:2015-07-20 09:19:30每周论坛发贴之星
日期:2015-07-20 09:19:42ChinaUnix元老
日期:2015-07-20 11:04:38荣誉版主
日期:2015-07-20 11:05:19巳蛇
日期:2015-07-20 11:05:26CU十二周年纪念徽章
日期:2015-07-20 11:05:27IT运维版块每日发帖之星
日期:2015-07-20 11:05:34操作系统版块每日发帖之星
日期:2015-07-20 11:05:36程序设计版块每日发帖之星
日期:2015-07-20 11:05:40数据库技术版块每日发帖之星
日期:2015-07-20 11:05:432015年辞旧岁徽章
日期:2015-07-20 11:05:44
3 [报告]
发表于 2010-06-20 22:17 |只看该作者
这个例子好简单。根本没有问题。你自己新建一个Android应用就是这样的。看看是不是ADT插件没有装好。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP