为什么调用自定义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 如何停止线程 android平板用linux? 64位Ubuntu下adb命令不能使用 求教:如何获得wappush发送方号码 android怎么成功调用自己写的jar包 android开发地图求助 android 跨程序通信 android for C++ndk调用接口函数adk停止运行//接口函数的格式是什么? android 课程设计 offer选择 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>