I am using a drag and drop format that kids drag a word from one cell in a column from a table and drop it on the corresponding cell in another column of the same table. This works well and no issues. what I would like it to vary the order of the cells that can be dragged. Currently the order is the same every time the activity open what I would like is that it was different every time the activity was opened. This is the code for the table.
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow>
<ImageView
android:id="@+id/catpic"
android:tag="cat"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/cat" />
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/blankbtn" />
<ImageView
android:id="@+id/cat"
android:tag="cat"
android:layout_width="100dp"
android:layout_height="100dp"
android:gravity="start"
android:src="@drawable/catw"/>
</TableRow>
<TableRow>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="@+id/dogpic"
android:tag="dog"
android:src="@drawable/dog" />
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/blankbtn" />
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="@+id/dog"
android:tag="dog"
android:gravity="start"
android:src="@drawable/dogw"/>
</TableRow>
<TableRow>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/panda"
android:id="@+id/pandapic"
android:tag="panda" />
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/blankbtn" />
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:gravity="start"
android:id="@id/panda"
android:tag="panda"
android:src="drawable/pandaw"/>
</TableRow>
<TableRow>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/cow"
android:id="@id/cowpic"
android:tag="cow"/>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/blankbtn" />
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:gravity="start"
android:id="@id/cow"
android:tag="cow"
android:src="@drawable/coww"/>
</TableRow>
<TableRow>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/chicken"
android:id="@id/chickenpic"
android:tag="chicken" />
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/blankbtn" />
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:gravity="start"
android:id="@id/chicken"
android:tag="chichen"
android:src="@drawable/chickenw" />
</TableRow>
</TableLayout>
The only images that need to be randomized are the one with id's cat, dog, panda, cow and chicken the others can remain in the same place every time the activity open.
I know this will will have to be handled in the java but can not work out how to be done.
I have looked for similar questions but can not5 find. Any help wee appreciated.
Aucun commentaire:
Enregistrer un commentaire