From d84808ffdbabfa49d6ac7e6b7ae516672fb4d9a4 Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Sun, 25 Apr 2010 19:33:05 +0200 Subject: [PATCH] UsersActivity: Return selected user --- src/org/yaaic/activity/UsersActivity.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/org/yaaic/activity/UsersActivity.java b/src/org/yaaic/activity/UsersActivity.java index aec0f52..4a527df 100644 --- a/src/org/yaaic/activity/UsersActivity.java +++ b/src/org/yaaic/activity/UsersActivity.java @@ -24,16 +24,20 @@ import org.yaaic.R; import org.yaaic.model.Extra; import android.app.ListActivity; +import android.content.Intent; import android.os.Bundle; +import android.view.View; import android.view.Window; +import android.widget.AdapterView; import android.widget.ArrayAdapter; +import android.widget.AdapterView.OnItemClickListener; /** * User Activity - Shows a list of users in the current channel * * @author Sebastian Kaspari */ -public class UsersActivity extends ListActivity +public class UsersActivity extends ListActivity implements OnItemClickListener { /** * On create @@ -48,5 +52,17 @@ public class UsersActivity extends ListActivity String[] users = getIntent().getExtras().getStringArray(Extra.USERS); getListView().setAdapter(new ArrayAdapter(this, R.layout.useritem, users)); + getListView().setOnItemClickListener(this); + } + + /** + * On user selected + */ + public void onItemClick(AdapterView list, View item, int position, long id) + { + Intent intent = new Intent(); + intent.putExtra(Extra.USER, (String) getListView().getAdapter().getItem(position)); + setResult(RESULT_OK, intent); + finish(); } }