Почему Android imeActionId в EditText - activity.xml показывает ошибку Неверный тип ресурса? - PullRequest
0 голосов
/ 04 октября 2018

изучение программирования на Android Я пытаюсь запустить этот пример: https://abhiandroid.com/programming/shared-preference

Это фрагмент моего EditText в activity_login.xml

            <EditText
                    android:id="@+id/password"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/prompt_password"
                    android:imeActionId="@+id/login"
                    android:imeActionLabel="@string/action_sign_in_short"
                    android:imeOptions="actionUnspecified"
                    android:inputType="textPassword"
                    android:maxLines="1"
                    android:singleLine="true"/>

Моя IntelliJ IDEA все еще показывает ошибку встрока:

android: imeActionId = "@ + id / login"

поговорка: неверный тип ресурса, ожидаемое целочисленное значение

Естественно, в LoginActivity.java есть ошибка "Не можетразрешить символ логин ":

    @Override
    public boolean onEditorAction(TextView textView, int id, KeyEvent  keyEvent) {
        if (id == R.id.login || id == EditorInfo.IME_NULL) {
            attemptLogin();
            return true;
        }
        return false;
     }

Это мой build.gradle:

    android {
    compileSdkVersion 26
    buildToolsVersion "28.0.2"
    defaultConfig {
        applicationId "com.tcc.andsharedpreferences"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
   testInstrumentationRunner
  "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support.constraint:constraint-layout:1.1.3'
    compile 'com.android.support:design:26.1.0'
    testCompile 'junit:junit:4.12'
    androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
}

Можете ли вы помочь мне?Я не понимаю, почему Android жалуется на тип imeActionId, если он должен его создавать (@ + id) ????

1 Ответ

0 голосов
/ 04 октября 2018

Вы можете определить целое значение в своих ресурсах:

<!--res/values/integers.xml-->
<resources>
<item type="integer" name="customImeActionId" format="integer">100</item>
</resources>

и использовать его следующим образом:

android:imeActionId="@integer/customImeActionId"

Пожалуйста, обратитесь к этому ТА вопрос дляподробнее

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...