开发者

How do i convert this to XML layout format?

开发者 https://www.devze.com 2023-04-07 00:30 出处:网络
This is the code comming from the Activity file. I would like to have the layout looks the same but i want that code in XML format. Because it\'s so damn disturbing to have some code in dynamically an

This is the code comming from the Activity file. I would like to have the layout looks the same but i want that code in XML format. Because it's so damn disturbing to have some code in dynamically and some in XML files. So please can someone make this from dynamically to xml layout?

    protected void initLayout() {

    // root view - GRN
    LinearLayout rootView = new LinearLayout(this.getApplicationContext());
    rootView.setOrientation(LinearLayout.VERTICAL);

    this.mText = new TextView(this.getApplicationContext());
    this.mText.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT));
    rootView.addView(this.mText);

    this.eventLayout = new LinearLayout(this.getApplicationContext());
    this.eventLayout.setOrientation(LinearLayout.VERTICAL);
    ScrollView sv_obj = new ScrollView(this.getApplicationContext());
    sv_obj.addView(this.eventLayout);
    开发者_如何转开发rootView.addView(sv_obj);
    this.setContentView(rootView);

}


<LinearLayout android:orientation="vertical>
    <TextView android:width="wrap_content  android:height="wrap_content/>
    <ScrollView>
        <LinerLayout android:orientation="vertical> 
        </LinearLayout>
    </ScrollView>
</LinearLayout>
0

精彩评论

暂无评论...
验证码 换一张
取 消