setting number to a clicked item of android gridview -
i new android programming. question might easy not soln. want set empty gridview , set number starting 1 , increasing when clicked @ item of gridview. can set gridview not set number clicked item. can help? thanks... here code;
public class mainactivity extends activity {
gridview grid; string[] numbers = new string[] { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); grid = (gridview) findviewbyid(r.id.gridview); arrayadapter adapter = new arrayadapter(this, android.r.layout.simple_list_item_1,numbers); grid.setadapter(adapter); grid.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { // todo auto-generated method stub numbers[position]="1"; } }); }
if modifying underlying data store of adapter
, reflect changes in ui, notifydatasetchanged()
method needs invoked.
Comments
Post a Comment