我对 Android 开发比较陌生。
但我想知道是否可以移动这些图像,以便它们可以在网格中相互交换。因为它是我正在尝试实现的棋盘游戏。
这就是它的样子:http: //i.imgur.com/2shAuGd.png
图像数组的代码:
private Integer[] mThumbIds = {
R.drawable.blank, R.drawable.blank, R.drawable.peg, R.drawable.peg, R.drawable.peg, R.drawable.blank, R.drawable.blank,
R.drawable.blank, R.drawable.blank, R.drawable.peg, R.drawable.peg, R.drawable.peg, R.drawable.blank, R.drawable.blank,
R.drawable.peg, R.drawable.peg, R.drawable.peg, R.drawable.peg, R.drawable.peg, R.drawable.peg, R.drawable.peg,
R.drawable.peg, R.drawable.peg, R.drawable.peg, R.drawable.empty, R.drawable.peg, R.drawable.peg, R.drawable.peg,
R.drawable.peg, R.drawable.peg, R.drawable.peg, R.drawable.peg, R.drawable.peg, R.drawable.peg, R.drawable.peg,
R.drawable.blank, R.drawable.blank, R.drawable.peg, R.drawable.peg, R.drawable.peg, R.drawable.blank, R.drawable.blank,
R.drawable.blank, R.drawable.blank, R.drawable.peg, R.drawable.peg, R.drawable.peg, R.drawable.blank, R.drawable.blank,
};
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<GridView
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="40dp"
android:columnWidth="50dp"
android:numColumns="7"
android:verticalSpacing="2dp"
android:horizontalSpacing="2dp"
android:stretchMode="columnWidth"
android:gravity="center" />
</LinearLayout>