【发布时间】:2011-11-11 14:29:08
【问题描述】:
我在这里看到了一些关于这个问题的例子,但没有一个解决这个问题,观察下面的代码:
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");
}});
我的 oncreate 方法中有它,当我单击列表中的特定位置时,它不会打印 system.out。我想知道为什么会这样,我在另一个类中使用了这个确切的代码,它工作正常。我也有活动课的清单。如果有帮助,下面是xml。
<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>
【问题讨论】:
-
listview 行布局是什么样的?
-
如果您的列表视图中有复选框或其他内容,您可能会看到此错误code.google.com/p/android/issues/detail?id=3414。
-
在 onCreate() 中打印一个 System.out,看看它是否正在打印,然后告诉我它是否正在打印。
-
@JohnBoker 我没有指定行。但是,我认为确实有一个按钮,这可能是您所说的问题吗? AndroidKiller,是的 system.out 在 oncreate 中打印。
-
喜欢!它很有魅力。在下面添加您的答案,以便我将其选为正确
标签: android