我的列表视图未填充父项
2022-09-05 00:12:24
<RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" <TextView android:id="@+id/tv_test" android:text="Test " android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ListView android:id="@+id/list_test" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_below="@id/tv_test" ></ListView> </RelativeLayout>
一切都在ScrollView中,我不知道为什么,但相对布局似乎设置了包装内容。它使ListView变小,而不是占据整个位置。
我不知道它是否有用,但这是我的java代码:
public class ShowView extends Activity{
ListView lv;
ArrayAdapter<String> adapter;
String[] myList = {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Height", "Nine", "Ten"};
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.show);
lv = (ListView) findViewById(R.id.list_test);
adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, myList);
adapter.setDropDownViewResource(android.R.layout.simple_list_item_1);
lv.setAdapter(adapter);
}
}