[英]How can I edit an EditText field of MainActivity from ApplicationTest.java in Android Studio?
I want to write a Test (instrumentation unit test) in which I want to edit an EditText field instantiated in the MainActivity in order to test the output field (TextView) instantiated in the MainActivity where there are the data my app returned to me in real time.我想编写一个测试(仪器单元测试),其中我想编辑在 MainActivity 中实例化的 EditText 字段,以测试在 MainActivity 中实例化的输出字段(TextView),其中有我的应用程序实际返回给我的数据时间。
In other words, main problem is: how to read and modify objects instantiated in the MainActivity starting from an ApplicationTest.java file?换句话说,主要问题是:如何从 ApplicationTest.java 文件开始读取和修改 MainActivity 中实例化的对象?
Write method to Edit the edit text in main class and make this method public.编写方法在主类中编辑编辑文本并使该方法公开。 In another class make Instance of MainActivity and use that method
在另一个类中创建 MainActivity 的实例并使用该方法
You can make that method static also您也可以将该方法设为静态
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.