-1
でのListViewに私のカスタム・アダプターの最初のレコードと次のレコードを取得することができます
のxml:どのように私はbuttonClick
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_blue_dark"
tools:context="com.example.aref.teachingtorkmanlanguage.MainActivity">
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:dividerHeight="12dp">
</ListView>
</RelativeLayout>
項目のXML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@android:color/holo_blue_dark">
<ImageView
android:layout_width="240dp"
android:layout_height="200dp"
android:id="@+id/imgView"
android:layout_centerHorizontal="true"
android:background="@drawable/sib"/>
<Button
android:id="@+id/btnBack"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:background="@drawable/ic_arrow_back_black_24dp"/>
<Button
android:id="@+id/btnForward"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:background="@drawable/ic_arrow_forward_black_24dp"
android:layout_centerVertical="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/word"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_toRightOf="@id/btnBack"
android:layout_toEndOf="@id/btnBack"
android:layout_toLeftOf="@id/btnForward"
android:layout_toStartOf="@id/btnForward"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:textSize="40sp"
android:textColor="@android:color/white"
android:gravity="center"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/mean"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_below="@id/btnForward"
android:layout_marginTop="15dp"
android:textSize="40sp"
android:textColor="@android:color/white"
android:gravity="center"/>
</RelativeLayout>
ショー:
私はリストビューで自分のアダプタの最初のレコードを取得し、アイテム間をバックでナビゲートしたいボタンと進むボタン... どうすればいいですか? ................................................. .................
アイテムがlistViewに表示されたときにナビゲートするとはどういう意味ですか? –
アダプタを使用している場合は、アダプタの最初の項目を取得するために、位置のような参照をいくつか持つことができます。それが正しいか?したがって、最初の位置は0です –