我有一個全屏畫廊與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