我正在为Android编写一些Espresso测试.我正在运行以下问题:
为了使某个测试用例正常运行,我需要在应用程序中禁用某些功能.因此,在我的应用程序中,我需要检测我是否正在运行Espresso测试,以便我可以禁用它.但是,我不想使用BuildConfig.DEBUG,因为我不希望在调试版本中禁用这些功能.此外,我想避免创建一个新的buildConfig,以避免创建太多的构建变体(我们已经定义了很多风格).
我一直在寻找一种方法来定义buildConfigField以进行测试,但我在Google上找不到任何引用.
我正在尝试实现以下布局:
+----------------------------------------+
| [icon] [text] [icon] |
+----------------------------------------+
| [icon] [very loooooooooooooooooo [icon]|
| oooooooooooooooong text] |
+----------------------------------------+
Run Code Online (Sandbox Code Playgroud)
当文本很短时,右边的图标需要在文本旁边(不是右对齐).当文本很长时,我需要包装文本.
我曾尝试使用LinearLayout和RelativeLayout,但是当我有一个长文本时,图标仍然被推出.这是我尝试过的布局:
LinearLayout中:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="left"/>
<TextView
android:id="@+id/middle"
android:text="a long long string, a long long string, a long long string, a long long string, a long long string, a long long string, "
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#D0E198"/>
<TextView
android:id="@+id/right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="right"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
RelativeLayout的:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="left"/>
<TextView
android:id="@+id/middle"
android:text="a …Run Code Online (Sandbox Code Playgroud) 记录泛型类型适用于直接继承。但是当我有一个继承链时,没有办法让它适用于孙子类。这是一个例子:
* @property {string} color
* @template {T}
*/
class MyColor {
constructor() {
this.color = 'unknown';
}
/**
* @returns {T}
*/
static makeColor() {
return /**@type {T}*/ new this.prototype.constructor();
}
}
/**
* @extends MyColor<Red>
* @template {T}
*/
class Red extends MyColor {
constructor() {
super();
this.color = 'red';
}
}
/**
* @extends Red<DarkRed>
*/
class DarkRed extends Red {
constructor() {
super();
this.level = 2;
}
darker() {
this.level += 1;
}
}
const circle …Run Code Online (Sandbox Code Playgroud) 我在CardView中有一个TextView.通过添加OnClick事件并添加属性为CardView上的Lollipop启用涟漪效果时:
android:foreground="?android:attr/selectableItemBackground"
它工作正常.但是在向TextView添加OnClick事件后,当我单击TextView外部时,仍会显示涟漪效果,但在单击TextView区域时它不会显示.
即使我单击TextView,是否还有显示波纹?
这是xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<android.support.v7.widget.CardView
android:id="@+id/news_card"
android:foreground="?android:attr/selectableItemBackground"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/text"
android:text="Test String"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.v7.widget.CardView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这是代码:
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main);
View v = findViewById (R.id.news_card);
v.setOnClickListener (new View.OnClickListener () {
@Override public void onClick (final View v) {
}
});
View textView = findViewById (R.id.text);
textView.setOnClickListener (new View.OnClickListener () {
@Override public void onClick (final View v) {
}
});
}
Run Code Online (Sandbox Code Playgroud) android android-layout android-cardview android-5.0-lollipop
我有5个分片,我想将它们合并为一个分片.每个分片都有大约30GB的数据.我可以使用"removeShard"命令逐个删除它们.但这很浪费,因为当我逐个删除分片时,数据必须重新分配多次.强制数据移动到我将保留到最后的单个分片会更有效.