我有一个全屏画廊与setOnItemClickListener
和setOnItemSelectedListener
。在这个画廊我有一个线性布局3个ImageViews。我已经准备好了可以点击的图像浏览器,但是当我点击它们时,gallery.setOnItemClickListener
就是被激活的。我怎样才能让他ImageViews点击?ImageView不在画廊中可点击
塔布局完整的layot是非常复杂的,所以我把相关部分的图像。
在代码中,我有:
ImageView prev = (ImageView) findViewById(R.id.previousImage);
ImageView play = (ImageView) findViewById(R.id.playAllImages);
ImageView next = (ImageView) findViewById(R.id.nextImage);
prev.setClickable(true);
prev.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
YADA YADA YADA ...
}
});
next.setClickable(true);
next.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
YADA YADA YADA ...
}
});
play.setClickable(true);
play.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
YADA YADA YADA ...
}
});
我也有画廊的听众:
_horizGallery.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
YADA YADA YADA...
}
});
_horizGallery.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView parent, View view,
int position, long id) {
YADA YADA YADA...
}
public void onNothingSelected(AdapterView parent) {
YADA YADA YADA...
}
});
的XML是这样的(我拿出一些非相关部件使其更小以供实际使用):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="horizontal"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:background="#11000000" android:layout_alignParentBottom="true"
android:weightSum="1.0" android:id="@+id/layoutToScrollDown">
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:layout_weight="0.1" android:gravity="center">
<ImageView android:layout_width="30dp" android:layout_height="30dp" android:src="@drawable/icon"
android:padding="1px" android:id="@+id/previousImage"> </ImageView>
</LinearLayout>
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:layout_weight="0.4" android:gravity="center">
<ImageView android:layout_width="30dp" android:layout_height="30dp" android:src="@drawable/icon"
android:padding="1px" android:id="@+id/playAllImages"> </ImageView>
</LinearLayout>
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:layout_weight="0.1" android:gravity="center">
<ImageView android:layout_width="30dp" android:layout_height="30dp" android:src="@drawable/icon"
android:padding="1px" android:id="@+id/nextImage"> </ImageView>
</LinearLayout>
</LinearLayout>
<com.pixable.android.ModifiedGallery xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.pixable.android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/HorizontalGallery"
android:gravity="center_vertical" android:spacing="2px"/>
这一切都因为某些原因没有beine显示相对视图中。
比你,让我试试看,看看它是怎么回事,但我已经移动,所以如果它解决了我要杀死自己的问题。关于额外的线性布局,在我的应用程序中,我有5个图像(问题背景中的代码比需要的更大),所以我简化了实际使用,布局需要以必要的间距显示图像。 – 2011-04-07 00:44:05
它的工作。谢谢。现在我必须自杀(开玩笑)。奇怪的是,我最初在相对布局的按钮上有图像(我甚至打开应用程序的最后一个版本,只是为了让它在问之前像这样)。 Eclipse必须有一个解析问题(这个问题已经多次发生在我身上)。 – 2011-04-07 00:54:43