I’ve seen a few examples on here to this problem, but none have solved this issue, observe the code below:
mProductList = hotdealhelper.getCatalog(getResources());
ListView myListView = (ListView) findViewById(R.id.listViewoffers);
myListView.setAdapter(new hotdealadapter(mProductList, getLayoutInflater()));
myListView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
System.out.println("Newbie");
}});
I have it in my oncreate lethod, and when I click on a particular position in the list, it is not printing the system.out. I am wondering why this is, I have used this exact code in another class and it works fine. I have the list in a activity class also. Below is the xml if it helps.
<ImageView android:id="@+id/imageView1" android:src="@drawable/dealheader" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true"></ImageView> <ListView android:layout_height="wrap_content" android:id="@+id/listViewoffers" android:layout_width="match_parent" android:layout_marginTop="35px"></ListView> <Button android:text="Button" android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="0px" android:layout_alignParentBottom="true"></Button>
You may have forgotten the @Override
EDIT
Maybe you’re seeing this bug http://code.google.com/p/android/issues/detail?id=3414 if you have a checkbox or something in your listview. remove the button and see if it works… if it does that was the problem.