安爬 2016-04-27 15:48 采纳率: 50%
浏览 2136
已结题

Android开发入门学习中遇到的问题

Android初学者,使用的书籍是《第一行代码Android》在书中2.2.5在活动中使用Toast这个部分出现了问题代码编写并未报错,虚拟机中按menu键没有出现菜单栏,请问这是什么原因该如何解决。拜托各位了。图片说明

图片说明问题没有解决,在虚拟机中点击Menu依旧没有出现菜单栏,请问还有哪些问题?拜托了

  • 写回答

9条回答

  • devmiao 2016-04-27 15:51
    关注

    在学习Android开发的过程中遇到了不少的问题,所幸的是最终经过上网查询都得到了解决。现在将我在学习Android开发过程中遇到的一些问题及解决的方法整理如下。

    1.R.java不能实时更新

      问题描述:在res文件中新增的变量不能在R.java中实时的显示出来。

      解决方法:选择菜单栏的“Project”,勾选“Build Automatically”选项。

    2.LogCat视窗没有显示

      问题描述:在Eclipse的右下方没有显示LogCat视窗。

      解决方法:选择菜单栏的“Windows”,再选择“Show View”,最后再选择“LogCat”即可。

    3.编译时提示“android library projects cannot be launched”错误的解决方法

      问题描述:编译时提示“android library projects cannot be launched”错误

      解决方法:选择菜单栏的“Project”,再选择“Properties”,在弹出的窗口中选择“Android”,将is library选项前面的勾去掉。

    4.在xml中添加EditText控件后提示“This text field does not specify an inputType or a hint”错误

      问题描述:在xml中添加EditText控件,控件信息如下。

     <EditText
         android:id="@+id/editText"
         android:layout_width="match_parent"
         android:layout_height="wrap_content" ></EditText>
    

      编译时,提示“This text field does not specify an inputType or a hint”错误。

      原因分析:控件中缺少android:hint以及android:inputType信息。android:hint用于设置EditText为空时显示的默认文字提示信息。android:inputType用于设置EditText的文本的类型,用于帮助输入法显示合适的键盘类型。

      解决方法:在控件中添加android:hint以及android:inputType信息,添加后的控件信息如下。

     <EditText
         android:id="@+id/editText"
         android:hint="0"
         android:inputType="number"
         android:layout_width="match_parent"
         android:layout_height="wrap_content" ></EditText>
    

    5.警告信息“Hardcoded string "xxx", should use @string resource”的消除方法

      问题描述:在xml中添加Button控件,控件信息如下。

     <Button
         android:id="@+id/mButton_mc"
         android:text="mc"
         android:layout_width="match_parent"
         android:layout_height="wrap_content" >           
     </Button>
    

      编译时,提示“Hardcoded string "mc", should use @string resource”警告。

      原因分析:在android:text中使用到了字符串mc,应该将该字符串定义在String.xml中,然后再通过调用String.xml中该字符串的资源名来使用该字符串资源。这样做的好处在于可以做到一改全改,并且在支持多语言时也是很有用处的。

      解决方法:在项目目录下的res-->values-->String.xml中添加字符串mc的信息如下。

      
      mc

      

      然后,再在使用该Button控件的xml中,通过调用该字符串的资源名来使用该字符串,如下。

      <Button
          android:id="@+id/mButton_mc"
          android:text="@string/mc"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" >           
      </Button>
    

    6.警告信息“Nested weights are bad for performance”的消除方法

      原因分析:在布局进行嵌套使用时,父布局与子布局都使用了android:layout_weight,但不是必须使用时,便会出现如题所示的警告信息。

      解决方法:根据实际情况,去除子布局中非必须使用的android:layout_weight。

    7.启动模拟器时出现错误信息“Please ensure that adb is correctly located at:XXXXX”的解决方法

      现象:使用正确的源代码,在启动模拟器时出现如下错误信息“Please ensure that adb is correctly located at 'D:\AndroidSDK4.0\android-sdk-windows\platform-tools\adb.exe' and can be executed.”

      解决方法:将D:\AndroidSDK4.0\android-sdk-windows\platform-tools加入到系统环境变量PATH中。

    8.模拟器启动时一直显示信息“Waiting for HOME ('android.process.acore') to be launched...”的解决方法

      现象:模拟器启动时,等很久(5分钟以上)也启动不了,一直提示“Waiting for HOME ('android.process.acore') to be launched...”信息。

       解决方法:删除当前的模拟器,重新创建一个模拟器。在学习Android开发的过程中遇到了不少的问题,所幸的是最终经过上网查询都得到了解决。现在将我在学习Android开发过程中遇到的一些问题及解决的方法整理如下。

    1.R.java不能实时更新

      问题描述:在res文件中新增的变量不能在R.java中实时的显示出来。

      解决方法:选择菜单栏的“Project”,勾选“Build Automatically”选项。

    2.LogCat视窗没有显示

      问题描述:在Eclipse的右下方没有显示LogCat视窗。

      解决方法:选择菜单栏的“Windows”,再选择“Show View”,最后再选择“LogCat”即可。

    3.编译时提示“android library projects cannot be launched”错误的解决方法

      问题描述:编译时提示“android library projects cannot be launched”错误

      解决方法:选择菜单栏的“Project”,再选择“Properties”,在弹出的窗口中选择“Android”,将is library选项前面的勾去掉。

    4.在xml中添加EditText控件后提示“This text field does not specify an inputType or a hint”错误

      问题描述:在xml中添加EditText控件,控件信息如下。

     <EditText
         android:id="@+id/editText"
         android:layout_width="match_parent"
         android:layout_height="wrap_content" ></EditText>
    

      编译时,提示“This text field does not specify an inputType or a hint”错误。

      原因分析:控件中缺少android:hint以及android:inputType信息。android:hint用于设置EditText为空时显示的默认文字提示信息。android:inputType用于设置EditText的文本的类型,用于帮助输入法显示合适的键盘类型。

      解决方法:在控件中添加android:hint以及android:inputType信息,添加后的控件信息如下。

     <EditText
         android:id="@+id/editText"
         android:hint="0"
         android:inputType="number"
         android:layout_width="match_parent"
         android:layout_height="wrap_content" ></EditText>
    

    5.警告信息“Hardcoded string "xxx", should use @string resource”的消除方法

      问题描述:在xml中添加Button控件,控件信息如下。

     <Button
         android:id="@+id/mButton_mc"
         android:text="mc"
         android:layout_width="match_parent"
         android:layout_height="wrap_content" >           
     </Button>
    

      编译时,提示“Hardcoded string "mc", should use @string resource”警告。

      原因分析:在android:text中使用到了字符串mc,应该将该字符串定义在String.xml中,然后再通过调用String.xml中该字符串的资源名来使用该字符串资源。这样做的好处在于可以做到一改全改,并且在支持多语言时也是很有用处的。

      解决方法:在项目目录下的res-->values-->String.xml中添加字符串mc的信息如下。

      
      mc

      

      然后,再在使用该Button控件的xml中,通过调用该字符串的资源名来使用该字符串,如下。

      <Button
          android:id="@+id/mButton_mc"
          android:text="@string/mc"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" >           
      </Button>
    

    6.警告信息“Nested weights are bad for performance”的消除方法

      原因分析:在布局进行嵌套使用时,父布局与子布局都使用了android:layout_weight,但不是必须使用时,便会出现如题所示的警告信息。

      解决方法:根据实际情况,去除子布局中非必须使用的android:layout_weight。

    7.启动模拟器时出现错误信息“Please ensure that adb is correctly located at:XXXXX”的解决方法

      现象:使用正确的源代码,在启动模拟器时出现如下错误信息“Please ensure that adb is correctly located at 'D:\AndroidSDK4.0\android-sdk-windows\platform-tools\adb.exe' and can be executed.”

      解决方法:将D:\AndroidSDK4.0\android-sdk-windows\platform-tools加入到系统环境变量PATH中。

    8.模拟器启动时一直显示信息“Waiting for HOME ('android.process.acore') to be launched...”的解决方法

      现象:模拟器启动时,等很久(5分钟以上)也启动不了,一直提示“Waiting for HOME ('android.process.acore') to be launched...”信息。

       解决方法:删除当前的模拟器,重新创建一个模拟器。在学习Android开发的过程中遇到了不少的问题,所幸的是最终经过上网查询都得到了解决。现在将我在学习Android开发过程中遇到的一些问题及解决的方法整理如下。

    1.R.java不能实时更新

      问题描述:在res文件中新增的变量不能在R.java中实时的显示出来。

      解决方法:选择菜单栏的“Project”,勾选“Build Automatically”选项。

    2.LogCat视窗没有显示

      问题描述:在Eclipse的右下方没有显示LogCat视窗。

      解决方法:选择菜单栏的“Windows”,再选择“Show View”,最后再选择“LogCat”即可。

    3.编译时提示“android library projects cannot be launched”错误的解决方法

      问题描述:编译时提示“android library projects cannot be launched”错误

      解决方法:选择菜单栏的“Project”,再选择“Properties”,在弹出的窗口中选择“Android”,将is library选项前面的勾去掉。

    4.在xml中添加EditText控件后提示“This text field does not specify an inputType or a hint”错误

      问题描述:在xml中添加EditText控件,控件信息如下。

     <EditText
         android:id="@+id/editText"
         android:layout_width="match_parent"
         android:layout_height="wrap_content" ></EditText>
    

      编译时,提示“This text field does not specify an inputType or a hint”错误。

      原因分析:控件中缺少android:hint以及android:inputType信息。android:hint用于设置EditText为空时显示的默认文字提示信息。android:inputType用于设置EditText的文本的类型,用于帮助输入法显示合适的键盘类型。

      解决方法:在控件中添加android:hint以及android:inputType信息,添加后的控件信息如下。

     <EditText
         android:id="@+id/editText"
         android:hint="0"
         android:inputType="number"
         android:layout_width="match_parent"
         android:layout_height="wrap_content" ></EditText>
    

    5.警告信息“Hardcoded string "xxx", should use @string resource”的消除方法

      问题描述:在xml中添加Button控件,控件信息如下。

     <Button
         android:id="@+id/mButton_mc"
         android:text="mc"
         android:layout_width="match_parent"
         android:layout_height="wrap_content" >           
     </Button>
    

      编译时,提示“Hardcoded string "mc", should use @string resource”警告。

      原因分析:在android:text中使用到了字符串mc,应该将该字符串定义在String.xml中,然后再通过调用String.xml中该字符串的资源名来使用该字符串资源。这样做的好处在于可以做到一改全改,并且在支持多语言时也是很有用处的。

      解决方法:在项目目录下的res-->values-->String.xml中添加字符串mc的信息如下。

      
      mc

      

      然后,再在使用该Button控件的xml中,通过调用该字符串的资源名来使用该字符串,如下。

      <Button
          android:id="@+id/mButton_mc"
          android:text="@string/mc"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" >           
      </Button>
    

    6.警告信息“Nested weights are bad for performance”的消除方法

      原因分析:在布局进行嵌套使用时,父布局与子布局都使用了android:layout_weight,但不是必须使用时,便会出现如题所示的警告信息。

      解决方法:根据实际情况,去除子布局中非必须使用的android:layout_weight。

    7.启动模拟器时出现错误信息“Please ensure that adb is correctly located at:XXXXX”的解决方法

      现象:使用正确的源代码,在启动模拟器时出现如下错误信息“Please ensure that adb is correctly located at 'D:\AndroidSDK4.0\android-sdk-windows\platform-tools\adb.exe' and can be executed.”

      解决方法:将D:\AndroidSDK4.0\android-sdk-windows\platform-tools加入到系统环境变量PATH中。

    8.模拟器启动时一直显示信息“Waiting for HOME ('android.process.acore') to be launched...”的解决方法

      现象:模拟器启动时,等很久(5分钟以上)也启动不了,一直提示“Waiting for HOME ('android.process.acore') to be launched...”信息。

       解决方法:删除当前的模拟器,重新创建一个模拟器。

    评论

报告相同问题?

悬赏问题

  • ¥15 C#调用python代码(python带有库)
  • ¥15 矩阵加法的规则是两个矩阵中对应位置的数的绝对值进行加和
  • ¥15 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面
  • ¥50 NT4.0系统 STOP:0X0000007B