我想使用圖像單元格來顯示一些圖像集合在我的應用程序內顯示一些圖像集合在主列表中查看代碼工作正常,圖像顯示在列表視圖中,但問題是所有單元格只顯示2個圖像(我已經在gridview佈局中指定了2個列),而我已經填充了5個圖像的GridView列表!GridView作爲列表視圖單元格不顯示所有項目
她是我的佈局:
主要的ListView,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.mtids.gridviewaslistviewcell.MainActivity">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/LV" />
</LinearLayout>
和GridView的佈局,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<GridView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:numColumns="2"
android:scrollbars="vertical"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:id="@+id/cgrid" />
</LinearLayout>
和ImageView的單元佈局,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
app:srcCompat="@mipmap/ic_launcher"
android:id="@+id/cimage" />
</LinearLayout>
任何想法會很多ppreciated
您是否嘗試從網格視圖中刪除numColumns? –
你可以參考這個網址:http://stackoverflow.com/a/27353336/5860087 –
仍然不能正常工作 –