
findviewbyid 无法解析id
xml中<Buttonandroid:id="@+id/button"android:layout_width="wrap_content"android:layout_...
xml中
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="111"/>
.java中
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button = (Button) this.findViewById(R.id.button); //出现无法解析id的问题
button.setOnClickListener(this);//出现setOnClickListener参数不适用的问题
}
包都导入了 展开
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="111"/>
.java中
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button = (Button) this.findViewById(R.id.button); //出现无法解析id的问题
button.setOnClickListener(this);//出现setOnClickListener参数不适用的问题
}
包都导入了 展开
1个回答
展开全部
是运行中出的错吧。
你把this去掉试试。或者改成 类名.this.findViewById(R.id.button);
你把this去掉试试。或者改成 类名.this.findViewById(R.id.button);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询