
android开发在main.xml中添加控件的时候android:id="@+id/myButton"是什么意思?
比如<Buttonandroid:id="@+id/myButton"android:layout_width="fill_parent"android:layout_h...
比如 <Button
android:id="@+id/myButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/> 展开
android:id="@+id/myButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/> 展开
2个回答
展开全部
为这个Button定义一个变量名,以便在代码中通过这个变量对button进行操作。@+id表示新添加一个id,如果引用系统的id可以用@android:id/ 。。。其中myButton为变量名。
代码中通过。Button t = (Button)findViewById(R.id.myButton);
这样便得到了该button对象,可以进行更多操作。
代码中通过。Button t = (Button)findViewById(R.id.myButton);
这样便得到了该button对象,可以进行更多操作。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |