0
我有一個Activity
帶有項目列表。通過點擊一個項目,它會彈出第二個Activity
,並在第一個Activity
中點擊該項目的詳細信息。顯示列表查看第二項活動詳情活動
我的第一活動:(我傳遞一個string[]
經由Intent
)我的第二活性
Bundle bundle= new Bundle();
bundle.putStringArray("item_details", new String[]{item_name, item_desc, item_date, item_loc});
Intent intent = new Intent(getApplicationContext(), DataProductDetail.class);
intent.putExtras(extras);
:(接收string[]
)
Bundle bundle = this.getIntent().getExtras();
String[] itemArray = bundle.getStringArray("item_details");
ArrayAdapter<String> itemArrayAdapter = new ArrayAdapter<String>(this, R.layout.list_item, itemArray);
ListView list = (ListView)findViewById(R.id.list);
detailsList.setAdapter(itemArrayAdapter);
佈局LIST_ITEM:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="18sp"
android:textColor="#0c2d63" />
我的問題/問題:
我希望我的應用程序第一個屏幕,看起來像這樣(這是工作):
item1
item2
item3
問題:
的第二個屏幕當item1
被點擊時第一個Activity
應該是這樣的(不知道如何得到這個,上面的代碼不起作用):
Name: xyz is "item_name" from array "itemArray" received from intent
Description: This is the description from "item_desc" from array "itemArray"
Date: This is the date string grabbed from item_date from array "itemArray"
如何獲得如上面第二個屏幕所示的佈局?我想要Name, Description, Date
顯示在第二個屏幕上,並將數組中的某些元素分別顯示爲項目詳細信息。