为什么调用自定义Button控件不能正常显示窗口 你的activity_main.xml中使用Button的地方改成com.xxx.xxx.MyButton(就是你的 包名.MyButton),那么MyButton my=(MyButton)findViewById(R.id.buttonOK);这句话是可以正常显示。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 谢谢ncepu307你的回答,但是在Button中没有找到你要求改的地方,我将XML代码显示,请教在现有的代码中如何写,谢谢:)<RelativeLayout 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=".MainActivity" > <Button android:id="@+id/buttonOK" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/textView1" android:layout_centerHorizontal="true" android:layout_marginTop="62dp" android:text="Button" /></RelativeLayout> <com.xxx.xxx.MyButton android:id="@+id/buttonOK" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/textView1" android:layout_centerHorizontal="true" android:layout_marginTop="62dp" android:text="Button" /></RelativeLayout> 你在layout布局文件中button要用你自定义的button的包名+类名 已经很明显了,XML中引用Button是系统自己的Button,自定义的必须给出完整的路径,也就是包名.MyButton 关于桌面悬浮框弹回的问题!! 跪求android4.0开发入门书籍Pdf 安卓智能机如何连接网络中的PLC android provider中的authorities可以有多个么? 超级好的 android 音乐播放器 源码 安装android 报错 send mms 异常 新手--关于android主程序不能之间访问网络的问题 小白求助-百度地图api无法定位 在Android Studio里基本方法的用不了 android studio使用 请教java里gson解析问题
<RelativeLayout 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=".MainActivity" > <Button
android:id="@+id/buttonOK"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="62dp"
android:text="Button" /></RelativeLayout>
android:id="@+id/buttonOK"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="62dp"
android:text="Button" /></RelativeLayout>