私はあなたの問題を再現することはできません。 Android Studio 2.2.2では、新規プロジェクトウィザードから「空のアクティビティ」をテンプレートとして選択し、appcompatオプションをオフにして新しいプロジェクトを作成しました。その後、activity_main.xml
に、私はあなたの目的の文字列を参照するようにTextView
を変更:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/activity_main"
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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.commonsware.myapplication.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@android:string/cancel" />
</RelativeLayout>
これはきれいに構築し、アンドロイド7.1上で実行されます。
APIレベル1以降、その文字列がSDKに含まれていたため、使用する際に問題は発生しません。
"これはうまくいかないようです" - うーん...私はそれが働くことを期待しています。あなたの特定の症状は何ですか? – CommonsWare
@CommonsWare:Androidスタジオは「Can not resolve symbol」と言います。これは 'android:'部分をオートコンプリートしますが、 'string /'部分を書くときにはもうツールチップを表示しません。 – Marcel50506
'@ string/cancel'を使用 –