Define onClick Events In Another Class
Hello :) I have several classes which call the onItemClick event of the same ListView and there is quite a lot of code inside each one, and all the 开发者_如何转开发code is the same. I've seen other people define the onClick event in another class, how would i go about doing this?
Any examples or tutorials would be much appreciated. Thanks
I think what jpm mean was "implement":
public class Blah implements OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//do stuff!
}
}
Define a class which extends OnItemClickListener do the stuff you want to do in its onItemClick method and set this listener as the lisviews onItemClickListener...
精彩评论