andbase icon indicating copy to clipboard operation
andbase copied to clipboard

abactivity中一个地方,有点想法

Open lf951515851 opened this issue 9 years ago • 3 comments

public void setContentView(int layoutResID) {
        super.setContentView(layoutResID);
        initIocView();
    }

public void setAbContentView(View contentView) {
        contentLayout.removeAllViews();
        contentLayout.addView(contentView,new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        //ioc
        initIocView();
    }

中都有initIocView();在实践开发中如果这样:

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);//父类方法中会调用setContentView
        setAbContentView(R.layout.activity_main);
    }

就会调用两次initIocView();如果界面定义的iocview比较多的话,性能会有较大影响

lf951515851 avatar May 29 '15 01:05 lf951515851

谢谢反馈 这应该是一个bug,稍后我们会修复这个问题

2015-05-29

zhaoqp2010

发件人:lf951515851 [email protected] 发送时间:2015-05-29 09:59 主题:[andbase] abactivity中一个地方,有点想法 (#3) 收件人:"zhaoqp2010/andbase"[email protected] 抄送:

public void setContentView(int layoutResID) { super.setContentView(layoutResID); initIocView(); } 和 public void setAbContentView(View contentView) { contentLayout.removeAllViews(); contentLayout.addView(contentView,new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); //ioc initIocView(); } 中都有initIocView();在实践开发中如果这样: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);//父类方法中会调用setContentView setAbContentView(R.layout.activity_main); } 就会调用两次initIocView();如果界面定义的iocview比较多的话,性能会有较大影响 — Reply to this email directly or view it on GitHub.

ym6745476 avatar May 29 '15 02:05 ym6745476

/**
     * 描述:用指定的View填充主界面.
     * @param contentView  指定的View
     */
    public void setAbContentView(View contentView) {
        contentLayout.removeAllViews();
        contentLayout.addView(contentView,new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    }

将setAbContentView()中的initIocView();去掉不太好吧.

@AbIocView(id = R.id.mText)TextView mTextView;

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);//父类方法中会调用setContentView
        setAbContentView(R.layout.activity_main);
    }

这样控件是获取不到的,demo中的ioc实例就出现这样的问题了,感觉还是将setContentView中的initIocView()去掉,只使用setAbContentView

lf951515851 avatar Jun 02 '15 01:06 lf951515851

ok 谢谢

2015-06-03

zhaoqp2010

发件人:lf951515851 [email protected] 发送时间:2015-06-02 09:10 主题:Re: [andbase] abactivity中一个地方,有点想法 (#3) 收件人:"zhaoqp2010/andbase"[email protected] 抄送:"zhaoqp"[email protected]

/** * 描述:用指定的View填充主界面. * @param contentView 指定的View */ public void setAbContentView(View contentView) { contentLayout.removeAllViews(); contentLayout.addView(contentView,new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

}

将setAbContentView()中的initIocView();去掉不太好吧. @AbIocView(id = R.id.mText)TextView mTextView;

protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);//父类方法中会调用setContentView setAbContentView(R.layout.activity_main); } 这样控件是获取不到的,demo中的ioc实例就出现这样的问题了,感觉还是将setContentView中的initIocView()去掉,只使用setAbContentView — Reply to this email directly or view it on GitHub.

ym6745476 avatar Jun 03 '15 01:06 ym6745476