And*_*Eve 2 android unit-testing
我按照Hello,Testing教程的说法.
但是,以下行产生"com.example.helloandroid.R.id无法解析"错误:
mView = (TextView) mActivity.findViewById(com.example.helloandroid.R.id.textview);
Run Code Online (Sandbox Code Playgroud)
Eclipse令人惊讶地提出了2个快速修复:
你能帮我理解这些修正是什么意思吗?这些确实是正确的修复方法吗?(为什么教程也没有提供它们?)
在HelloAndroid项目中,HelloAndroid.java
setContentView(R.layout.main);
Run Code Online (Sandbox Code Playgroud)
检查你的HelloAndroid项目,在"gen-> com.example.helloandroid-> R.java"中有如下代码:
public static final class id {
public static final int textview=0x7f050000;
}
Run Code Online (Sandbox Code Playgroud)
如果不是,请检查"res-> layout-> main.xml".有"android:id ="@ + id/textview"如下?
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/hello"/>
Run Code Online (Sandbox Code Playgroud)
检查这些项目,如果需要,修复HelloAndroid.java和/或main.xml.重建HelloAndroid项目,并重建HelloAndroidTest项目.
| 归档时间: |
|
| 查看次数: |
8717 次 |
| 最近记录: |