Android layout TextView元素中预期的资源类型id android id问题
这是我的xml文件,我在其中创建了一个id为welcome的TextView 我试了很多,但没有得到适当的结果Android layout TextView元素中预期的资源类型id android id问题,android-layout,Android Layout,这是我的xml文件,我在其中创建了一个id为welcome的TextView 我试了很多,但没有得到适当的结果 <TextView android:id="@+id/welcome" android:text="@string/hello_world" android:layout_width="wrap_content" android:layout_height="wrap_content" > // mainact
<TextView
android:id="@+id/welcome"
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
// mainactivity.java class
TextView newView;// declare object of textview
@Override
newView=(TextView) findViewById(R.layout.welcome);
}
//mainactivity.java类
TextView newView;//声明textview的对象
@凌驾
newView=(TextView)findViewById(R.layout.welcome);
}
//此处错误,需要类型id的资源。(R.layout.welcome)//此处显示错误,需要类型资源id。请帮助我是新安卓您必须使用文本视图的id(安卓:id=“@+id/welcome”),即欢迎。 因此,不要使用R.layout.welcome,而要使用R.id.welcome,它会起作用。不要写:
newView=(TextView) findViewById(R.layout.welcome);
写下:
newView=(TextView) findViewById(R.id.welcome);