把程序配置到手机上,程序直接就挂掉了
在logcat 可以看见错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myyt.savefiletosdcard/com.myy.savefiletosdcard.MainActivity}: java.lang.ClassCastException: android.widget.Button cannot be cast to android.widget.EditText
错误的代码
xml中
</pre><p><pre name="code" class="html"> <Button
android:id="@+id/bt_msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="saveMsg"
android:text="保存" />
MainActivity中
<pre name="code" class="java"> protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et_msg = (EditText) findViewById(R.id.bt_msg);
}
很明显的错误.....
组件类型都不一样 把类型弄一致就ok了