我正在使用Eclipse Galileo進行Android「Hello,Testing」教程。 (http://developer.android.com/resources/tutorials/testing/helloandroid_test.html)當我嘗試編譯並運行程序時,出現錯誤,提示「com.example.helloandroid.R.id無法解析」。Android編程錯誤
package com.example.helloandroid.test;
import com.example.helloandroid.HelloAndroid;
import android.test.ActivityInstrumentationTestCase2;
import android.widget.TextView;
public class HelloAndroidTest extends ActivityInstrumentationTestCase2<HelloAndroid>
{
private HelloAndroid mActivity; // the activity under test
private TextView mView; // the activity's TextView (the only view)
private String resourceString;
public HelloAndroidTest()
{
super("com.example.helloandroid", HelloAndroid.class);
}
@Override
protected void setUp() throws Exception
{
super.setUp();
mActivity = this.getActivity();
mView = (TextView) mActivity.findViewById(com.example.helloandroid.R.id.textview);
resourceString = mActivity.getString(com.example.helloandroid.R.string.hello);
}
public void testPreconditions()
{
assertNotNull(mView);
}
public void testText()
{
assertEquals(resourceString,(String)mView.getText());
}
}
感謝您提供任何幫助/建議!
請發表你的全部代碼。您可能錯過了導入。 – birryree 2010-11-22 21:01:26