Hallo,
ich habe auf meiner Main-Activitiy eine Liste. Jedes Listenelement wird über eine separate list_item.xml "designt".
Zur Identifikation von Einträgen möchte ich eine eindeutige ID benutzen, um mehr Daten zu dem Eintrag in der zweiten Activity "nachzuladen", aber NICHT alle Daten schon on das Listenelement packen.
Die Daten werden beim Parsen des JSON-Feeds in einer HashMap abgelegt. (Beispiel aus Internet)
Fragen: 
Kann ich auf die Daten der HashMap auch in der zweiten Activty zugreifen? 
Wie kann ich anhand der position des Elements in der Liste alle Daten aus der HashMap an die zweite Activity übergeben?
main_activity.xml
Code
		
					
			<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
 xmlns:tools="http://schemas.android.com/tools" 
 android:layout_width="fill_parent" 
 android:layout_height="fill_parent" 
 android:orientation="vertical" >
<ListView android:id="@android:id/list" 
 android:layout_width="fill_parent" 
 android:layout_height="wrap_content"/>
</LinearLayout>
	
			Alles anzeigen
	list_item.xml
Code
		
					
			<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 
<TextView android:id="@+id/evId" 
 android:layout_width="fill_parent" 
 android:layout_height="wrap_content" 
 android:visibility="invisible" /> 
 
<TextView 
 android:id="@+id/evTitle" 
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content" />
</LinearLayout>
	
			Alles anzeigen
	detail_activity.xml
Code
		
					
			<TextView android:id="@+id/evId" 
 android:layout_width="fill_parent" 
 android:layout_height="wrap_content" 
 android:visibility="invisible" /> 
 
<TextView 
 android:id="@+id/evTitle" 
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content" />
<TextView android:id="@+id/evCategory" 
 android:layout_width="fill_parent" 
 android:layout_height="wrap_content"  /> 
 
<TextView 
 android:id="@+id/evDestination" 
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content" />
	
			Alles anzeigen
	Lesen der Einträge aus JSON-Feed
Code
		
					
			/**
     * Async task class to get json by making HTTP call
     * */
    [b]private class GetEvents[/b] extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... arg0) {
... hier http-request ....
events = jsonObj.getJSONArray(TAG_ITEMS);
                    // looping through All Events
                    for (int i = 0; i < events.length(); i++) {
                        JSONObject c = events.getJSONObject(i);
                        String id = c.getString(TAG_ID);
                        String title = c.getString(TAG_TITLE);
                        String ort = c.getString(TAG_ORT);
                        String zip = c.getString(TAG_CATEGORY);
HashMap<String, String> event = new HashMap<String, String>();
                        event.put(TAG_ID, id);
                        event.put(TAG_TITLE, title);
                        event.put(TAG_ORT, ort);
                        event.put(TAG_ZIP, zip);
                    eventList.add(event);
                    }
           }
}
	
			Alles anzeigen
	
ListAdapter füllen
Code
		
					
			@Override
        protected void onPostExecute(Void result) {
            /**
             * Updating parsed JSON data into ListView
             * */
            ListAdapter adapter = new SimpleAdapter(
                    MainActivity.this, eventList,
                    R.layout.list_item, new String[] { TAG_ID, TAG_TITLE, TAG_ZIP,
                    TAG_ORT, TAG_STREET, TAG_NUMBER, TAG_DATE, TAG_STIME, TAG_ETIME, TAG_CATEGORY_NAME }, new int[] { R.id.evId, R.id.evTitle,
                    R.id.evZIP, R.id.evOrt, R.id.evStreet, R.id.evNumber, R.id.evDate, R.id.evStartTime, R.id.evEndTime, R.id.evCategory });
            setListAdapter(adapter);
        }
	
			Alles anzeigen
	Code
		
					
			protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        eventList = new ArrayList<HashMap<String, String>>();
        ListView lv = getListView();
        // Listview on item click listener
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id)
            {
                // getting values from selected ListItem
                String evTitle = ((TextView) view.findViewById(R.id.evTitle)).getText().toString();
                String evZIP = ((TextView) view.findViewById(R.id.evZIP)).getText().toString();
                String evOrt = ((TextView) view.findViewById(R.id.evOrt)).getText().toString();
                String evCategory = ((TextView) view.findViewById(R.id.evCategory)).getText().toString();
                // Starting single contact activity
                Intent in = new Intent(getApplicationContext(),DisplayEventDetailActivity.class);
                in.putExtra(TAG_TITLE, evTitle);
                in.putExtra(TAG_ORT, evOrt);
                in.putExtra(TAG_ZIP, evZIP);
                in.putExtra(TAG_CATEGORY_NAME, evCategory);
                startActivity(in);
            }
        });
        // Calling async task to get json
        new GetEvents().execute();
    }
	
			Alles anzeigen