I wrote a class similar to .NET GridView for android but my mind went blank for one action! when I loop through rows (or data whatever) I want to fire an event which includes selected row on every row. You can think as if you are reaching each row separately with helping by rowdatabound on .NET.
for (int m = 0; m < this.columns.length; m++) {
do some stuff
fire()
}
Do I need to create a new thread or listener? If yes how do I do these and how do I catch it on the otherside? Please give me an idea.
with this codes which I wrote below, I can create a gridview and display it without any problem. I need to get every rows one by one but how?
DataGrid dgSiparis = new DataGrid(this,lnSiparis,dt); //CREATING THE DATAGRID, argumants: context, linearlayout, a class named datatable which runs similar to DataTable on .NET, dt object has rows)
dgSiparis.setDataBind();
The answer:
- create an interface for listener
- implement your class with it (for this example DataGrid class will be implement it)
- set it where you loop through rows
- catch the listener you create on the instance class (for this ex dgSiparis)
There are no events in Java, instead it uses Observer – Listener pattern. Have a look at this article for details:
http://www.vogella.de/articles/DesignPatternObserver/article.html