问题描述
- The specified child already has a parent.
-
求各位大神帮我看看,我这段程序哪里出现了父类?
final SimpleAdapter mSchedule = new SimpleAdapter(this, grouplist, R.layout.groupinfo, new String[]{"groupinfo", "groupinfotext"}, new int[]{R.id.groupinfos, R.id.groupinfotext})
{
//在这个重写的函数里设置 每个 item 中按钮的响应事件
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final int p = position;
final View view = super.getView(position, convertView, parent);
Button button = (Button) view.findViewById(R.id.btnstate);
button.setOnClickListener(new View.OnClickListener() {@Override public void onClick(View v) { //警告框的写法 new AlertDialog.Builder(GroupActivity.this) .setTitle("More") .setMessage("你选中了" + String.valueOf(p)) .setPositiveButton("确定", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { setTitle("点击了对话框上的确定按钮"); } }) .create() .show(); } }); return view; } }; GInfoView.setAdapter(mSchedule); GInfoView.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); GInfoView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(getApplicationContext(),"被点击了!",Toast.LENGTH_LONG).show(); } }); //触发点击事件的函数 setContentView(GInfoView); }
解决方案
http://www.cnblogs.com/kissazi2/archive/2012/10/05/2712664.html
解决方案二:
今天写代码的时候出现了这个错误,功能很简单:在一个Activity中有一个ListBox,长按其中一条数据会出现编辑框,点击确定之后就跳转到令一个Activity
第一次进行跳转没什么问题,按返回键在按编辑就挂掉了,出现了下面的错误
The specified child already has a parent. You must call removeView() on the......
答案就在这里:The specified child already has a parent.
解决方案三:
@caozhy 我看了这篇文章,还是没找到我的错误啊?
时间: 2024-12-28 13:15:02