Remain: 5
2 Answers
Bùi Đắc
Beginner
Bùi Đắc
Beginner
data dạng [{title:1, data[1,2,3,4,5]},{title: 2, data: [a,b,c,x,y,z]},{title:3, data[m,l]}]
-
0
monkey
Beginner
monkey
Beginner
Đây là code
activity_main.xml
:
<span><span><?</span>xml version=<span>"1.0"</span> encoding=<span>"utf-8"</span><span>?></span></span> <span><<span>androidx.constraintlayout.widget.ConstraintLayout</span> <span>xmlns:android</span>=<span>"http://schemas.android.com/apk/res/android"</span> <span>xmlns:tools</span>=<span>"http://schemas.android.com/tools"</span> <span>android:layout_width</span>=<span>"match_parent"</span> <span>android:layout_height</span>=<span>"match_parent"</span> <span>xmlns:app</span>=<span>"http://schemas.android.com/apk/res-auto"</span> <span>tools:context</span>=<span>".MainActivity"</span>></span> <span><<span>TextView</span> <span>android:text</span>=<span>"Title1"</span> <span>android:layout_width</span>=<span>"wrap_content"</span> <span>android:layout_height</span>=<span>"wrap_content"</span> <span>android:id</span>=<span>"@+id/textView"</span> <span>android:layout_marginTop</span>=<span>"16dp"</span> <span>app:layout_constraintLeft_toLeftOf</span>=<span>"parent"</span> <span>app:layout_constraintTop_toTopOf</span>=<span>"parent"</span> /></span> <span><<span>GridView</span> <span>android:id</span>=<span>"@+id/idGVcourses"</span> <span>android:layout_width</span>=<span>"match_parent"</span> <span>android:layout_height</span>=<span>"wrap_content"</span> <span>android:horizontalSpacing</span>=<span>"6dp"</span> <span>android:numColumns</span>=<span>"2"</span> <span>android:verticalSpacing</span>=<span>"6dp"</span> <span>app:layout_constraintTop_toBottomOf</span>=<span>"@id/textView"</span> <span>app:layout_constraintLeft_toLeftOf</span>=<span>"parent"</span>/></span> <span></<span>androidx.constraintlayout.widget.ConstraintLayout</span>></span>
Các đoạn code còn lại em tham khảo tại đây nhé: https://www.geeksforgeeks.org/gridview-in-android-with-example/
-
0