Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在linearlayout中使用其他xml文件动态创建framelayout_Java_Android - Fatal编程技术网

Java 如何在linearlayout中使用其他xml文件动态创建framelayout

Java 如何在linearlayout中使用其他xml文件动态创建framelayout,java,android,Java,Android,我搜索了一段时间,没有找到awnser,我必须说,我对创建应用程序非常陌生 我从sqlite数据库中读取分类(名称、描述)(我不知道这个数据库中有多少分类) 现在,我创建了一个包含linearlayout(水平)的水平滑块 在这个linearlayout中,我将动态创建framelayout(像其他framelayout、linearlayout等一样包含自定义xml代码) 我不知道如何插入xml 我希望有人能帮我找到解决这个问题的办法 ---编辑--- 主要活动 public class Ma

我搜索了一段时间,没有找到awnser,我必须说,我对创建应用程序非常陌生

我从sqlite数据库中读取分类(名称、描述)(我不知道这个数据库中有多少分类)

现在,我创建了一个包含linearlayout(水平)的水平滑块

在这个linearlayout中,我将动态创建framelayout(像其他framelayout、linearlayout等一样包含自定义xml代码)

我不知道如何插入xml

我希望有人能帮我找到解决这个问题的办法

---编辑---

主要活动

public class MainActivity extends Activity {

int scr_w, scr_h;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);

    scr_w = size.x;
    scr_h = size.y;

    LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.menu_box_layout, null, false);

    LinearLayout llTest = (LinearLayout)findViewById(R.id.horilila);
    //Create the Menu Boxes here
    for(int i =1;i<=6; i++){

        FrameLayout flTest = new FrameLayout(this);
        flTest.addView(v, scr_w, LayoutParams.MATCH_PARENT);

        flTest.setId(i + 10);
        //Insert the new FrameLayout into the LinearLayout
        llTest.addView(flTest);

    }
}
公共类MainActivity扩展活动{
内部scr_w,scr_h;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Display Display=getWindowManager().getDefaultDisplay();
点大小=新点();
display.getSize(size);
scr_w=尺寸x;
scr_h=尺寸y;
LayoutFlater充气器=(LayoutFlater)getSystemService(Context.LAYOUT\u充气器\u服务);
视图v=充气机。充气(R.layout.menu\u box\u layout,null,false);
LinearLayout llTest=(LinearLayout)findViewById(R.id.Horilla);
//在这里创建菜单框

对于(int i=1;i让我们假设您有一个xml,您可以从中获得如下视图:

LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.<your_xml>, null, false);

假设您有一个xml,您可以从中获得如下视图:

LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.<your_xml>, null, false);

假设您有一个xml,您可以从中获得如下视图:

LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.<your_xml>, null, false);

假设您有一个xml,您可以从中获得如下视图:

LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.<your_xml>, null, false);
FrameLayout看起来怎么样?FrameLayout看起来怎么样?FrameLayout看起来怎么样?FrameLayout看起来怎么样?