بروز خطا
   [message]
اشتراک در سوال
رای ها
[dataList]
پرسش و پاسخ

ارور You must call removeView() on the childs parent first در addView

مدیریت گفتگو
سعید 10 سال پیش
آخرین تغییر: 10 سال پیش

سلام.

من دارم با ارور 

ارور You must call removeView() on the child's parent first در addView

مواجه میشم.بید چیکارش کنم؟

سرچ هم کردم اما نتیجه نداد راه حلشون 

 

 public class PriceActivity extends ActivityEnhanced {

    public ViewGroup                 scrPrice;
    public ViewGroup                 viewLoop;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_price);
        //scrPrice = (ViewGroup) findViewById(R.id.scrPrice);
        viewLoop = (ViewGroup) findViewById(R.id.viewLoop);
        LayoutInflater inflater = getLayoutInflater();
        View view = inflater.inflate(R.layout.adapter_price, null);
        for(int i=0;i<20;i++){
            TextView txtResellerprice = (TextView) view.findViewById(R.id.txtResellerprice);
            TextView txtMarketprice = (TextView) view.findViewById(R.id.txtMarketprice);
            txtResellerprice.setText("saeed");
            txtResellerprice.setTypeface(App.FONT_BOLD);
            txtMarketprice.setText(i + 3 + "");
            txtMarketprice.setTypeface(App.FONT_BOLD);
            
            viewLoop.addView(view);
        }
    }
    
}

 

 

نظرات

پاسخ‌ها 1

محمد 10 سال پیش

قبل از

            viewLoop.addView(view);

کد زیر رو وارد کن:

 if (view.getParent() != null){
((ViewGroup) view.getParent()).removeView(view);
}

 

نظرات


پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .