当您尝试在视图中添加mdescrition时

mDescriptHelp = (TextView)view.findViewById(R.id.id_descript_help);
mDescriptHelp.setTypeface(mFontUtils.getBentonSansMediumFont());

TelephonyManager manager =
         (TelephonyManager)mActivity.getSystemService(Context.TELEPHONY_SERVICE);

if(manager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE){

    FrameLayout.LayoutParams params =
                new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                                             LayoutParams.WRAP_CONTENT);
    params.setMargins(800, 290, 10, 0);
    layout.addView(mDescriptHelp, params);
}


我的错误是

03-16 06:27:07.452: E/AndroidRuntime(7233): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.


我不明白这个错误。任何想法?我希望有人能帮助我。

最佳答案

更改此行

layout.addView(mDescriptHelp, params);




mDescriptHelp.setLayoutParams(params);


我认为就是这样。

10-07 20:50