Combine common part

OnItemClickListener has been put to basic function so that gridview and
listview can use