unfortunately ,....has stopped问题求解决

dongtao1010 2014-04-20 03:09:28
我按照网上给的教学视频编写一个多选框的案例,程序编译是对的,但是当apk程序在虚拟机上运行的时候就出现unfortunately ,....has stopped这样的错误
错误一
具体代码如下:
//main_activity.java
package com.dylan.s01_e09_checkbox;

import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.CheckBox;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}

/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {

public PlaceholderFragment() {
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container,
false);
CheckBox eatBox = (CheckBox)rootView.findViewById(R.id.eatId);
CheckBox sleepBox = (CheckBox)rootView.findViewById(R.id.sleepId);
CheckBox dotaBox = (CheckBox)rootView.findViewById(R.id.dotaId);

OnBoxClickListener listener = new OnBoxClickListener();
eatBox.setOnClickListener(listener);
sleepBox.setOnClickListener(listener);
dotaBox.setOnClickListener(listener);


return rootView;
}
}
public static class OnBoxClickListener implements OnClickListener{

@Override
public void onClick(View arg0) {
System.out.println("Checkbox is clicked");
}

}

}

红色字体部分是我添加的代码。。。
fragment_main.xml文件如下:

<LinearLayout 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:orientation="vertical"
tools:context="com.dylan.s01_e09_checkbox.MainActivity$PlaceholderFragment" >

<CheckBok
android:id="@+id/eatId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="吃饭" />

<CheckBok
android:id="@+id/sleepId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="睡觉" />

<CheckBok
android:id="@+id/dotaId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dota" />

</LinearLayout>


出现错误的logcat代码如下:
04-20 06:26:29.158: E/AndroidRuntime(1107): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dylan.s01_e09_checkbox/com.dylan.s01_e09_checkbox.MainActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class CheckBok

错误二
还有就是在我每次保存main_activity文件的时候总会跳出
'Running Android Lint' has encountered a problem
An internal error occurred during :"Running Android Lint"


虽然这个错误提示不影响整体的运行结果,但总是看到心里还是不舒服的。。。
请问这些问题怎么解决啊,大神求帮忙了。。。
...全文
2218 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
酒比花香 2014-04-25
  • 打赏
  • 举报
回复
网上说貌似是64位的系统装了32位的eclipse会出现这种情况
dongtao1010 2014-04-20
  • 打赏
  • 举报
回复
引用 2 楼 hjywyj 的回复:
CheckBox不是CheckBok
大哥,第二个问题求帮忙解决一下呗
dongtao1010 2014-04-20
  • 打赏
  • 举报
回复
引用 2 楼 hjywyj 的回复:
CheckBox不是CheckBok
谢谢,我搞错了,那第二个问题怎么解决啊。。。
  • 打赏
  • 举报
回复
CheckBox不是CheckBok
dongtao1010 2014-04-20
  • 打赏
  • 举报
回复
终于发成功了,话说最近网站是不是加载出现问题了

80,472

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧