我想以编程方式更改 TextInputLayout 的轮廓,但我似乎无法让它工作。有一个选项可以通过 XML 完成(其他 SO 用户使用 XML 提出的问题),但这对我来说无法使用,因为我需要动态着色。我目前有以下布局:
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:id="@+id/color_outline"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/color"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Choose color"/>
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
我试图通过查看 TextInputLayout 的各种框方法来应用着色,但它没有任何效果。
internal fun String.toIntColor() = Integer.parseInt(this.replaceFirst("#", ""), 16)
val colorOutline: TextInputLayout = view.findViewById(R.id.color_outline)
colorOutline.boxStrokeColor = "#006699".toIntColor()
Run Code Online (Sandbox Code Playgroud)
如何动态着色,如下图所示?
android android-edittext android-textinputlayout material-components material-components-android
我想在用户点击操作按钮时清除通知.我在stackoverflow和谷歌搜索了很多,尝试了很多,但都失败了.所以我想知道,如果有任何解决方案如何解决它?
我创建通知的代码:
final int NOTIFICATION_ID = 1;
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setSmallIcon(R.drawable.ic_info_black_24dp);
builder.setStyle(new NotificationCompat.BigTextStyle().bigText("Geschiedenis \nFrans \nDuits \nNatuurkunde \nWiskunde"));
builder.setContentTitle("Rooster: ");
builder.setOngoing(true);
builder.setAutoCancel(true);
builder.setDefaults(Notification.DEFAULT_ALL);
builder.setAutoCancel(true);
Intent showIntent = new Intent(this, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, showIntent, 0);
builder.addAction(android.R.drawable.ic_menu_close_clear_cancel, "Sluiten", contentIntent);
builder.setContentIntent(contentIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID, builder.build());
Run Code Online (Sandbox Code Playgroud)
所以要明确:一旦点击"Sluiten",我想清除(关闭)通知.
notifications android push-notification android-intent android-pendingintent
在学习使用Javadoc之前,我总是写内联注释。现在,我想知道,我如何能够有效地选择路线,并告诉一些关于它的Javadoc,而不是内部注释。
示例:
这是我的空白:
public void test() {
//This is a test sentence
String testSentence = "Test";
//This is another test sentence
String anotherTestSentence = "Test";
}
Run Code Online (Sandbox Code Playgroud)
如果没有其他(更有效的)方法,我该怎么做:
/**
* @line 2 This is a test sentence
* @line 3 This is another test sentence
*/
public void test() {
String testSentence = "Test";
String anotherTestSentence = "Test";
}
Run Code Online (Sandbox Code Playgroud)
有谁知道是否确实有更好的方法,还是应该使用内联注释而不是Javadoc?我注意到@line做了一些奇怪的事情,但是我找不到任何东西。
我有这个.travis.yml文件,但在构建时我经常收到此错误:
* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory '/home/travis/build/Me/MyProject/C:\Users\Me\AppData\Local\Android\Sdk' does not exist.
Run Code Online (Sandbox Code Playgroud)
我的.travis.yml
language: android
before_install:
- chmod +x gradlew
script:
- ./gradlew clean assembleDebug
install:
- true
- chmod +x ./gradlew; ls -l gradlew; ./gradlew wrapper -v
android:
components:
# Uncomment the lines below if you want to
# use the latest revision of Android SDK Tools
# - platform-tools
# - tools
# The BuildTools version used by your project
- …Run Code Online (Sandbox Code Playgroud)