我正在構建一個作爲大學項目的flashcards應用程序,並且希望水平滾動顯示卡片。我爲閃存卡設計本身構建了一個xml文件:在活動佈局中多次合併/包含xml佈局文件的最佳解決方案
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@drawable/whitenote" android:padding="3dp">
<ImageButton
android:id="@+id/imageButtonPins"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" android:background="@color/transparent" android:src="@drawable/pinselector"/>
<TextView
android:id="@+id/textViewWord"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageButton1"
android:layout_centerHorizontal="true"
android:text="Word" android:textColor="@color/black" android:paddingTop="30dp" android:textSize="20dp"/>
<TextView
android:id="@+id/textViewMeaning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textViewWord"
android:layout_centerHorizontal="true"
android:text="Meaning" android:textColor="@color/black"/>
</RelativeLayout>
我也創建了Class文件。
在活動佈局中,我還有幾個元素,因此在根級別上需要一個線性佈局。我已經能夠使用和使用佈局充氣器來顯示單個閃卡用於測試目的。
問題
在這兩個方面,在和佈局吹氣我一直無法獲得的ImageButton工作。我的問題是如何讓按鈕工作。
更新:管理讓ImageButton正在使用。意識到我必須處理活動中的onclick事件,而不是自定義適配器類。這應該讓我獲得的話,只要我可以跟蹤顯示「當前」閃存卡
此外,什麼是最好的方式來處理flashcard應用程序的滾動?我目前的計劃是使用HorizontalScrollView並對其進行自定義,因爲我需要(a)刷卡使閃卡只能移動到下一個(b)我需要關注「當前」閃存卡,因爲我需要來自其子女觀點的一些數據(即,該詞)。
'ImageButton'不能正常工作嗎?它不可見嗎?它沒有迴應嗎?什麼是錯的,你期望會發生什麼? – kabuko 2012-03-07 23:09:05
@Kabuko:我已經設法讓按鈕開始工作了。它沒有響應點擊事件,我意識到它必須在活動類中處理,而不是在自定義適配器類中處理。 – 2012-03-07 23:20:07