我有一个从JSON文件填充的事件列表。
格式为:将ListActivity的一个元素链接到另一个Activity(参数依赖)
{
"eventId" : "1",
"event" : "ABC",
"dateStart" : "20151223",
"dateEnd" : "20141201",
"pin" : false,
"attendees" : 233,
"location" : "London",
"description" : "A Test London event",
"photo" : "event1.jpg",
"status": "live",
"goals": [ "sales", "strategies", "HR", "product people", "data scientists", "investors", "designers", "laywers", "Media", "Sales", "Retailers", "PR"]
}
在我EventListActivity
,我填充这个JSON的多个元素的ArrayList<Event>
。点击一个事件时,我想要进入一个新的屏幕,显示该特定事件的所有目标。
所以在描述每个事件的视图中的XML,我有一个onClick
活动:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="180dp" android:paddingBottom="10dp" android:onClick="loadGoalScreen">
loadGoalScreen
然后继续应只显示所选活动的目标(目前它的下一个画面显示的目标String[] data = {"Strategists", "Human Resources", ...}
)的静态列表:
public void loadGoalScreen(View v) {
Intent intent = new Intent(EventListActivity.this, GoalCaptureActivity.class);
startActivity(intent);
}
我怎样才能让我的GoalCaptureActivity
屏幕知道仅显示与所选事件的目标是什么? I.e我怎么知道哪个事件被点击了,这样我就可以从ArrayList
中挑选正确的元素,然后将它传递给GoalCaptureActivity
类,我只会显示该特定活动的目标?
把所有的事件在ListView中添加按钮以显示下一个活动的信息? – Aquaballin