我目前正在嘗試製作一個應用程序,該應用程序在數據庫中存儲一些帶有額外信息的產品並在自定義列表視圖中顯示它。從這個列表視圖中,我希望能夠通過點擊其中一個產品並顯示新的活動來編輯數據庫信息。我已經設法通過製作一個單獨的listview佈局來實現一個自定義的listview佈局,並將其添加到列表視圖中,但我無法想出一個方法來實現攻絲。該活動還必須將來自該產品的信息傳遞給另一個活動,因此必須提取用於該挖掘行的信息才能以某種方式提取出來。繼承人的代碼:顯示所述列表視圖添加OnClickListener並從ListView中提取信息
活動:
有使用兩種佈局文件,所述文件products.xml是這個類的標準佈局和item_layout.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:orientation="horizontal" >
<TextView
android:id="@+id/tvProductNameList"
android:layout_width="175dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:inputType="textCapSentences"
android:text="Name"
android:textSize="20sp" />
<TextView
android:id="@+id/tvDateList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Date"
android:textSize="20sp" />
<TextView
android:id="@+id/tvAmountList"
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:layout_toLeftOf="@+id/tvDateList"
android:text="Mnt"
android:textSize="20sp" />
"
</RelativeLayout>
爲能夠幫助我的人致敬!