I'm working with carousel i just used the Caruosel source code from [codeProject][1] site
every thing worked good until i added the setOnItemClickListener func when i run the app it’s crashing how can i solve this crash to make my app work???
import com.name.w.R;
import com.name.controls.Carousel;
import com.name.controls.CarouselAdapter;
import com.name.controls.CarouselAdapter.OnItemClickListener;
public class NameActivity extends Activity {
/** Called when the activity is first created. */
Carousel care;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
care=(Carousel) findViewById(R.id.carousel);
care.setOnItemClickListener(new OnItemClickListener(){
public void onItemClick(CarouselAdapter<?> parent,View view,int position,long id){
Toast.makeText(NameActivity.this, "Position=" + position, Toast.LENGTH_SHORT).show();
}
});
}
}
Find view by ID is returning null. Please do a check for null after the below line.