https://github.com/bmelnychuk/AndroidTreeViewを使用してツリーベースのメニューを表示しています。私は確かに非常に基本的なものを逃していると私は私の間違いを確認する別の目が必要です。ライブラリによれば、ビューを動的に作成し(基本的にはスクロールビュー)、子としてRelativeLayoutに追加します。以下は私のレイアウトXMLRelativeLayoutに子ビューを追加できません
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/reload_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="re load menu" />
<RelativeLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/reload_menu"></RelativeLayout>
</RelativeLayout>
であり、ここで私が表示されている。このRelativeLayoutに
AndroidTreeView tView = new AndroidTreeView(getApplicationContext(), root);
RelativeLayout container = (RelativeLayout) findViewById(R.id.container);
container.addView(tView.getView());
のコード行は、例外なしに実行していても
、私はツリービューが表示されていないが、私のルートを追加してい方法です。私もtView.getView()をチェックし、それは完璧に見える。スクロールビューです。ある人が私を助けてくれますか?
ありがとう:
は、現在のコンテキスト(アクティビティコード)を使用しても試してみてください。もう少し理解したいと思います。高さをmatch_parentに変更しました。コードでは、子の高さと幅(この場合はtView)を設定しようとしています。 AndroidTreeViewはライブラリの一部であるため、私が使用できるsetLayoutParamsの実装はありません。子を追加した後にレイアウトを更新するために使用できる他のアイデアはありますか? –
もし動作していないのであれば、コードがアクティビティにある場合はgetApplicationContext()をこれに変更してみてください。 –