I have been struggling for a while to draw borders. I want to use a GridView to make a sliding puzzle game wheres the image is divided into squares and mixed up. Firstly, I have set up a GridView with String ArrayAdapter to just see how it will look.
It should look something like this. I just want to know how to make this frame with borders.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<GridView
android:id="@+id/gridView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="auto_fit">
</GridView>
</LinearLayout>
Inside Activity class:
String[] words = {"example","example1","example2"};
GridView grid;
public void onCreate(Bundle bund){
super.onCreate(bund);
setContentView(R.layout.grid_layout);
grid = (GridView) findViewById(R.id.gridView1);
grid.setAdapter(new ArrayAdapter<String>(MyActivity.this, android.R.layout.simple_list_item_1, words));
//grid.setOnItemClickListener(this);
And if I run this code I get a GridView without borders. I have already looked at similar questions but I still don`t know how to do it.
EDIT Looking at How to set border of GridView on Android.
EDIT: It appears that I needed to create resource colors.xml. By following the tutorial listed above it works. Thank you for the help provided.