我正在构建一个作为大学项目的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