I am having problem setting OnClickListener to my listview. I want to open different activities when different listview item is being clicked. But i am not able to get it done.
convertView = layoutInflater.inflate(R.layout.listview, parent, false);
below it,add
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (position == 1){
getActivity().startActivity(new Intent(MainActivity.this,secondActivity.class));
}else if (position == 2){
getActivity().startActivity(new Intent(MainActivity.this,secondActivity.class));
}else if (position == 3){
getActivity().startActivity(new Intent(MainActivity.this,secondActivity.class));
}
}
});