0

私は問題があります。

2 つの ViewStubs を使用して、画面を 2 つの領域に滑り込ませます。

しかし、ViewStub を膨らませると、アクセスできなくなり、この ViewStub 内の他の View を膨らませることができなくなります。

では、これらの種類のコンテナを使用する代替手段は何ですか。

ここにいくつかのコードがあります。あなたは皆、コードが大好きです:

    ViewStub contentSpace = (ViewStub) findViewById(R.id.ContentSpace);       
    contentSpace.setLayoutResource(R.layout.view1);
    contentSpace.inflate();
    contentSpace.setInflatedId(R.id.Content);
    RelativeLayout content = (RelativeLayout) findViewById(R.id.Content);

    contentSpace.setLayoutResource(R.layout.view1); //crash
    contentSpace.inflate();
4

2 に答える 2

-1

ここに私の解決策

rootLayout は、ViewStubs が配置されたリニア レイアウトです。

    rootLayout.removeView(contentLayout);
    inflater.inflate(R.id.view1, rootLayout);
    contentLayout = findViewById(R.id.contentLayout);

ビュー1:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal"    
        android:id="@+id/contentLayout">
[...]
于 2011-05-06T09:26:29.227 に答える