آموزش های این وب سایت به صورت رایگان در دسترس است. اطلاعات بیشتر
بروز خطا
   [message]
اشتراک در سوال
رای ها
[dataList]

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

سعید  9 سال پیش  9 سال پیش
0 0

سلام.

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

ارور 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 پاسخ وجود دارد.
پاسخ به سوال 
محمد  9 سال پیش
+2 0

قبل از

            viewLoop.addView(view);

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

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

 


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