小编Sai*_*man的帖子

错误:找不到符号类DataBindingComponent

我下载了一个Android项目,但是我收到了这个错误:

Error:(42, 42) error: cannot find symbol class DataBindingComponent
Run Code Online (Sandbox Code Playgroud)

样品导入:

import android.databinding.DataBindingComponent; // no code-time error
import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
Run Code Online (Sandbox Code Playgroud)

样品用法:

public FragmentFantasyPointsSingleBinding(DataBindingComponent bindingComponent, View root) {
        super(bindingComponent, root, 0);
        Object[] bindings = ViewDataBinding.mapBindings(bindingComponent, root, 4, sIncludes, sViewsWithIds);
        this.animationView = (LottieAnimationView) bindings[3];
        this.mboundView0 = (FrameLayout) bindings[0];
        this.mboundView0.setTag(null);
        this.progressView = (LinearLayout) bindings[2];
        this.recyclerView = (RecyclerView) bindings[1];
        setRootTag(root);
        invalidateAll();
    }
Run Code Online (Sandbox Code Playgroud)

代码时间没有错误,但在编译时我得到了我提到的错误.

当我尝试在Android Studio上进行定义时,我不能.

应用程序级build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.esports.flank"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName …
Run Code Online (Sandbox Code Playgroud)

java android gradle android-studio android-databinding

5
推荐指数
1
解决办法
5868
查看次数

在 ConstraintLayout 上设置 app:layout_constraintTop_toBottomOf

我认为仅通过使用app:layout_constraintTop_toBottomOf="@+id/label_proximity"就足以设置ImageView以下内容TextView。我需要使用marginTop才能使两者都TextView可见吗?或者我缺少任何属性?为什么在这种情况下约束不起作用?

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
tools:context=".MainActivity">

<TextView
    android:id="@+id/label_light"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/label_light"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<TextView
    android:id="@+id/label_proximity"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/label_proximity"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/label_light" />

<ImageView
    android:id="@+id/imageView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="50dp"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/label_proximity" />

</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

android android-constraintlayout

5
推荐指数
1
解决办法
1万
查看次数

Java - 带有冲突正则表达式的string.split

我最近遇到了这个问题,不知道如何解决它.我知道在String类中,我们有split方法接受正则表达式并且基于正则表达式,给定的字符串被拆分成不同的字符串并以字符串数组的形式返回.

例如,如果我有,

String s = "A,B,C";
Run Code Online (Sandbox Code Playgroud)

我做到了,

System.out.println(Arrays.toString(s.split(",")));
Run Code Online (Sandbox Code Playgroud)

它会将[A,B,C]打印到输出控制台.

现在让我们说我的字符串是

String s = "A,\"\"B\"\",\"\"C\"\",D";   //easier to read version: A,""B"",""C"",D
Run Code Online (Sandbox Code Playgroud)

我使用以下正则表达式来分割字符串,

String regex = ",|,\"\"|\"\",|\"\",\"\"";  // matches , OR ,"" OR "", OR "",""
System.out.println(Arrays.toString(s.split(regex)));
Run Code Online (Sandbox Code Playgroud)

我得到输出为[A,""B,""C,D].拆分如何在这里工作?我如何定义我的正则表达式,以便我得到[A,B,C,D]作为我的输出?

注意:我知道我想要实现的目标可以通过其他方式完成(例如replaceAll方法),但我只想使用String.split来解决这个问题,因为在这种情况下我想知道如何使用它.

java regex string split

3
推荐指数
1
解决办法
53
查看次数

oppo,vivo应用程序终止通知不在android fcm中出现

在Motorola中测试应用程序,当该应用程序被杀死时,三星可以正常工作。但是当我在体内测试应用程序时,oppo在应用程序被破坏的情况下无法正常工作。

 public void onMessageReceived(RemoteMessage remoteMessage) {
    Log.e(TAG, "From: " + remoteMessage.getFrom());

    if (remoteMessage == null)
        return;

    // Check if message contains a notification payload.
    if (remoteMessage.getNotification() != null) {
        Log.e(TAG, "Notification Body: " + remoteMessage.getNotification().getBody());
        //  handleNotification(remoteMessage.getNotification().getBody());
    }

    // Check if message contains a data payload.
    if (remoteMessage.getData().size() > 0) {
        Log.e(TAG, "Data Payload: " + remoteMessage.getData().toString());

        try {
            JSONObject json = new JSONObject(remoteMessage.getData().toString());
            handleDataMessage(json);
        } catch (Exception e) {
            Log.e(TAG, "Exception: " + e.getMessage());
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Android清单xml:

 <service …
Run Code Online (Sandbox Code Playgroud)

android push-notification firebase firebase-cloud-messaging

3
推荐指数
1
解决办法
3705
查看次数

如何更改在Android Studio底部导航栏中选择的图标颜色

当我在android studio底部导航栏中选择一个项目时,所选的背景项目等于values-> colors.xml中的primarycolor。现在我要更改与原色不同的颜色 我该如何更改?

    private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
            = new BottomNavigationView.OnNavigationItemSelectedListener() {
        Fragment fragment;
        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            switch (item.getItemId()) {
                case R.id.navigation_home:
                    fragment = new HomeFragment();
                    loadFragment(fragment);
                    return true;
                case R.id.navigation_addpost:
                    fragment = new AddFragment();
                    loadFragment(fragment);
                    return true;
                case R.id.navigation_notifications:
//                    mTextMessage.setText(R.string.title_notifications);
                    return true;
                case R.id.navigation_profile:
                    fragment = new ProfileFragment();
                    loadFragment(fragment);
                    return true;
            }
            return false;
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        loadFragment(new HomeFragment());
        BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
        navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
        navigation.setItemTextColor(ColorStateList.valueOf(Color.RED));
    }
Run Code Online (Sandbox Code Playgroud)

android bottomnavigationview

2
推荐指数
2
解决办法
9180
查看次数

如何将 LocalDateTime 转换为`"yyyy-MM-dd'T'HH:mm:ss'Z'"` 格式

我正在尝试将字符串的格式解析"yyyy-MM-dd'T'HH:mm:ss'Z'"LocalDateTime如果日期是sunday或者saturday我想将日期更改为monday相同格式并返回,我知道我可以通过使用添加天数plusDays

String str = "2018-09-22T12:30:10Z";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'");
LocalDateTime dateTime = LocalDateTime.parse(str, formatter);
System.out.println(dateTime.plusDays(2));  //2018-09-24T12:30:10
Run Code Online (Sandbox Code Playgroud)

但我想以格式返回 2018-09-24T12:30:10Z

java datetime date java-8

2
推荐指数
2
解决办法
1万
查看次数

在 Android Studio 中更改 Git 根

我有一个带有多个 git 子模块的 Android git 项目。出于某种原因,Android Studio git 集成选择了根作为子模块之一,因此我无法在“版本控制”窗格中看到我的更改。知道如何修改项目的 git 根吗?

我看到了这个:https://www.jetbrains.com/help/idea/configuring-cvs-roots.html,但我在 Android Studio 中没有 VCS Roots 窗口。

git android-studio android-studio-3.0

2
推荐指数
1
解决办法
1046
查看次数

从函数C ++返回float数组

我究竟做错了什么?

在第一个打印中,这些值很模糊,在第二个打印中,它们都是零。

第一次打印-q:0.965926 0.000000 0.258819 0.000000

第二次打印-q:0.000000 0.000000 0.000000 0.000000

float *AnglesToQaternion(float roll, float pitch, float yaw) { // Convert Euler angles in degrees to quaternions

    static float q[4];

    roll  = roll  * DEG_TO_RAD;
    pitch = pitch * DEG_TO_RAD;
    yaw   = yaw   * DEG_TO_RAD;

    float t0 = cosf(yaw * 0.5);
    float t1 = sinf(yaw * 0.5);
    float t2 = cosf(roll * 0.5);
    float t3 = sinf(roll * 0.5);
    float t4 = cosf(pitch * 0.5);
    float t5 = sinf(pitch * 0.5); …
Run Code Online (Sandbox Code Playgroud)

c++ arrays

1
推荐指数
1
解决办法
3025
查看次数

Android Kotlin-Facebook登录-获取用户数据

我是android开发的新手,已经搜索了数小时,却没有找到Facebook登录后如何获取该死用户数据的方法!

这是代码:

private var callbackManager: CallbackManager? = null

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_fb_connect)




        // Login
        callbackManager = CallbackManager.Factory.create()
        LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("public_profile", "email"))
        LoginManager.getInstance().registerCallback(callbackManager,
                object : FacebookCallback<LoginResult> {
                    override fun onSuccess(loginResult: LoginResult) {
                        Log.d("letsSee", "Facebook token: " + loginResult.accessToken.token)

                    }

                    override fun onCancel() {
                        Log.d("letsSee", "Facebook onCancel.")

                    }

                    override fun onError(error: FacebookException) {
                        Log.d("letsSee", "Facebook onError.")

                    }
                })

}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)

    callbackManager?.onActivityResult(requestCode, resultCode, data)

    Log.d("letsSee", "malsehnnnnnn: " + data)
} …
Run Code Online (Sandbox Code Playgroud)

android kotlin facebook-sdk-4.0

1
推荐指数
1
解决办法
4006
查看次数

嵌套while循环执行,外循环不执行

我是Java新手,目前我正在研究Vigenere密码/加密.我已经使用已知密钥进行了解密和加密,我现在唯一想做的就是字典攻击.为此,算法从文本文件中取一行并将其用作解密消息的密钥,然后它将获取该解密消息并再次将其与字典交叉引用(如果密钥产生了合法的单词,它将会使用该密钥解密其余的消息).

public static String decoderNoKey(String msg, Scanner words) {
Scanner words2 = words;
while (words.hasNextLine()) {
  String dicStr = words.nextLine();
  String result = decoder(msg, dicStr);

  while (words2.hasNextLine()) {
    String meta = words2.nextLine();
    if(result.equalsIgnoreCase(meta)) {
      System.out.println("Found a matching message: " + result);
      System.out.println("This is the corresponding key: " + dicStr);
      return meta;
    }
  }
 }
  return "There was no matching word";
}
Run Code Online (Sandbox Code Playgroud)

这是我的代码,解码器(); 方法工作得很好.如果我尝试输入一个合法的密码,问题是,外部while循环只执行一次(发现超出打印语句).单词文件也很大,84000+单词.

java loops while-loop

-1
推荐指数
1
解决办法
54
查看次数

为什么Kotlin的String为.length和.size为集合?

什么是这背后逻辑String.length,但是Collections.size.

kotlin

-2
推荐指数
1
解决办法
824
查看次数