-2
我的朋友 我是一個新的Android和我想做一個例子(代碼)喜歡的圖片 GridView控件 - 圖像,文本和項目單擊 感謝所有GridView控件 - 圖像,文本和項目單擊
我的朋友 我是一個新的Android和我想做一個例子(代碼)喜歡的圖片 GridView控件 - 圖像,文本和項目單擊 感謝所有GridView控件 - 圖像,文本和項目單擊
你正在尋找RecyclerView。創建佈局並添加recyclerView它然後創建了recyclerview下面的行另一個佈局文件:
<RelativeLayout
android:id="@+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
創建另一個佈局row_layout.xml
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/ic_launcher" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"/>
</RelativeLayout>
然後在你的MainActivity,加上下面幾行代碼:
RecyclerView recyclerView = findViewById(R.id.recyclerView);
recyclerView.setHasFixedSize(true);
RecyclerView.LayoutManager gridLayoutManager = new GridLayoutManager(this, 2, false);
recyclerView.setLayoutManager(gridLayoutManager);
在此之後,根據您的具體需要進行recyclerView可以用快速谷歌搜索發現創建一個適配器。只需在適配器的onCreateViewHolder中重新啓動row_layout即可。創建適配器後,只需將其設置爲您的recyclerView。
recyclerView.setAdapter(your_custom_adapter);
這只是你應該做的事情的要點。它會讓你開始正確的方向。其餘的只是一個搜索。
你應該開始尋找在線教程...問題太廣泛,因爲SO – Selvin
去Fiverr並付錢給你,讓它爲你 – Forbs
不要去fiverr,讓別人爲你做,他們會做它以最簡單快捷的方式,而不會考慮未來的問題。 –