在android系统中添加的LinearLayout到的LinearLayout [英] Adding LinearLayout to a LinearLayout in android

查看:102
本文介绍了在android系统中添加的LinearLayout到的LinearLayout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现这里很多关于增加的LinearLayout 动态问题。我还没有找到建议在那里我能知道的完整细节和步骤添加任何参考或任何教程或书籍的LinearLayout 动态。

I have found lots of question here regarding adding LinearLayout dynamically. I haven't found any reference or any tutorial or books suggested where I could know complete details of the and steps to add a LinearLayout dynamically.

    LinearLayout parentLayout = (LinearLayout) findViewById(R.id.master);
    LinearLayout Linear1 = new LinearLayout(this);
    Linear1.setOrientation(LinearLayout.HORIZONTAL);
    Linear1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT));
    parentLayout.addView(Linear1);

这是我使用了添加布局code片段。问题是,所需的最小API是11.我设计我的应用程序采用API 10.因此,它非常不好的消息我。请告诉我,有没有其他的方式来增加的LinearLayout 动态的较低的API?

This is the code snippet I am using for adding a Layout. The problem is that the min api required is 11. I have designed my app targeting api 10. So its very bad news for me. Please tell me is there any other way to add LinearLayout dynamically for the lower apis?

错误消息:拨打API需要11级(当前分钟为8):新android.app.ActionBar.LayoutParams

Error Message: Call requires API level 11 (current min is 8): new android.app.ActionBar.LayoutParams

推荐答案

您使用了错误的的LayoutParams 类。使用 LinearLayout.LayoutParams 而不是 ActionBar.LayoutParams

You are using the wrong LayoutParams class. Use LinearLayout.LayoutParams instead of ActionBar.LayoutParams.

这篇关于在android系统中添加的LinearLayout到的LinearLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆