I\'m attempting to work with through some tutorial code and add in an OnItemClick Listener, but keep throwing an exception when it hits the listener and crashing my app. This is
I am not sure your code will work
private OnItemClickListener newsSelectListener = new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView> parent, View view, int position, long id) {
AlertDialog.Builder alert=new AlertDialog.Builder(RssActivity.this);
alert.setTitle("Clicked").setMessage("Item clicked").setNeutralButton("OK", null).show();
}
};
But in my opinion, I often add setOnClickListener()
to convertView in getView
method in Adapter
class
public View getView(final int position, View convertView, ViewGroup parent) {
......................
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//Do Somethings in here
}
}
});