所以我试图按照谷歌的说明来测试我的活动:https : //developer.android.com/guide/components/activities/testing
但是代码launchActivity<MyActivity>()
不起作用。我是否需要将 launchActivity 定义为规则,或者是否需要在 gradle 中导入一个库?
这些是我已经拥有的进口
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
Run Code Online (Sandbox Code Playgroud) Dagger生成的文件和LiveData生成的绑定文件都会发生这种情况。
我将更改分支,为新的Live Data布局生成的文件或为新的daggeer组件生成的MemberInjector仍会存在,即使这些新组件实际上位于另一个分支上。
我将执行Invalidate缓存并重新启动以及进行干净的构建。但这是行不通的。我什至尝试手动删除文件,但它们只是重新生成。
我发现要修复它的唯一方法是卸载android studio并重新安装它。
我的使用Mac的同事没有遇到此问题。
我将文本视图上的文本设置为长度为 14,000,000 个字符的字符串。
加载到屏幕上需要 1 到 5 分钟(取决于设备)。有什么想法可以加快速度吗?
这是相关代码:
responseView.text = requestResponsePair.second
.....................
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context="com.salesrabbit.android.sales.universal.features.lumberjack.TextDisplayFragment">
<TextView
android:id="@+id/request_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/request_label_string"
android:textSize="20sp"/>
<TextView
android:id="@+id/text_view_request"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/response_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/response_label_string"
android:textSize="20sp"/>
<TextView
android:id="@+id/text_view_response"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我有一个用于一种方法的变量。因此,我的棉短绒告诉我将其本地化。但是我喜欢它是一个类级别的变量,以防其他任何人修改代码并需要使用该变量。如果不是类级别,他们可能会在方法中错过它并创建一个新的重复变量?
我的逻辑是否合理?还是应该将其设置为局部变量?
这是代码:
public class CustomPasswordTransformationMethod extends PasswordTransformationMethod {
. . .
private final char DOT_CHAR = '?';
. . .
public char charAt(int index) {
if (index < ((length()) - unObfuscated)) return DOT_CHAR;
return mSource.charAt(index);
}
}
Run Code Online (Sandbox Code Playgroud) 所以我有一个内部阶级:
public class RegressEquation
{
public List<float> coefficients = new List<float>();
float averageDiff = 0;
public RegressEquation(float[] coefficients, float finalAverageDiff)
{
averageDiff = finalAverageDiff;
foreach (float f in coefficients)
{
coefficients.Add(f);
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我调用coefficient.Add(f)时,我收到编译器错误; 说"System.Array不包含Add ...的定义"文档说Add()是List <>中的方法.我怎样才能摆脱这个错误?