error: Error: No resource found that matches the given name (at 'text' with value '@string/str_2')
MainActivity.java中的代码packagecom.example.irdc.ex03_01;importandroid.os.Bundle;importan...
MainActivity.java中的代码
package com.example.irdc.ex03_01;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;
public class MainActivity extends Activity {
private TextView mTextView01;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTextView01=(TextView) findViewById(R.id.mTextView01);
String str_2 = "欢迎来到Android的TextView世界!!!";
mTextView01.setText(str_2);
}
}
activity_main.xml中的代码
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_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=".MainActivity" >
<TextView
android:id="@+id/myTextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/str_2" //这里显示错误
android:layout_x="61px"
android:layout_y="69px"/>
</RelativeLayout> 展开
package com.example.irdc.ex03_01;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;
public class MainActivity extends Activity {
private TextView mTextView01;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTextView01=(TextView) findViewById(R.id.mTextView01);
String str_2 = "欢迎来到Android的TextView世界!!!";
mTextView01.setText(str_2);
}
}
activity_main.xml中的代码
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_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=".MainActivity" >
<TextView
android:id="@+id/myTextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/str_2" //这里显示错误
android:layout_x="61px"
android:layout_y="69px"/>
</RelativeLayout> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询