【发布时间】:2014-03-01 19:47:48
【问题描述】:
我在LinearLayout 内使用ListView,在LinearLayout 下方使用另一个LinearLayout,因为ListView 似乎占用了所有空间,所以不会显示。
代码:
listView = new ListView(this);
listView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
listLayout = new LinearLayout(this);
listLayout.setOrientation(LinearLayout.VERTICAL);
listLayout.addView(listView);
listLayout.addView(new NavigationBar(this, "android.intent.action.MAIN", "android.intent.action.MY_ACTIVITY"));
setContentView(listLayout);
NavigationBar 也是一个包含一些按钮的 LinearLayout。
如果添加在其上,它只会正常播放,如果在 ListView 之后添加,它根本不会显示。
【问题讨论】:
-
您错过了 listlayout 的 setlayoutparams。 gui开发最好使用布局文件
标签: android listview layout android-linearlayout