I would like to implement a gridview within Android, which will basically consist of 4 columns (it will be actiing similary to a table).
This will essentially be a list of items spread across 4 columns (name, qty, p1, p2). So each row contains 4 columns is unique to 1 items. Therefore, I need a way to bind these 4 columns together so that when i select anywhere within those 4 columns the whole row will be selected, whilst returning the 'name' column as the text id.
Is there an easy way that this can be done? This is my current code for the gridView:
XML Layout:
<GridView
android:id="@+id/gvShopCompleteList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/spnShopCharacters"
android:layout_above="@+id/linerBuyBtns"
android:numColumns="1"
android:fastScrollEnabled="true"
android:scrollbarStyle="insideOverlay">
</GridView>
Binding of Dynamic content:
GridView gridview;
static final String[] listItems = new String[] { "name","qty","p1","p2","itemname","5","100","1" };
gridview = (GridView)findViewById(R.id.gvShopCompleteList);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, listItems);
gridview.setAdapter(adapter);
gridview.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View v,int position, long id)
{
Toast.makeText(getApplicationContext(),
((TextView) v).getText(), Toast.LENGTH_SHORT).show();
}
});
Finally, an additional feature I would like to add is to make the header read only and highlighted a different color to the other rows. Any help would be much appreciated here, I do not have to use GridView, but would like to keep the generic android look as much as possible (consistant throughout my app). Thanks.