public void getFollowers() { final ArrayList<User> fetched_followers = Session.getFollowers(Session.viewed_user.id); List<Map<String, String>> followers = new ArrayList<Map<String, String>>(); for (int i = 0; i < fetched_followers.size(); i++) { try { HashMap<String, String> follower = new HashMap<String, String>(); follower.put( "follower", fetched_followers.get(i).first_name + " " + fetched_followers.get(i).last_name); followers.add(follower); } catch (Exception e) { } } ListView followers_list = (ListView) findViewById(R.id.followers_lv); SimpleAdapter followers_adapter = new SimpleAdapter( this, followers, android.R.layout.simple_list_item_1, new String[] {"follower"}, new int[] {android.R.id.text1}); followers_list.setAdapter(followers_adapter); followers_list.setOnItemClickListener( new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parentAdapter, View view, int position, long id) { Session.viewed_user = fetched_followers.get(position); Intent i = new Intent(Followers.this, Profile.class); startActivity(i); } }); }
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.to_profile) { Session.viewed_user = Session.current_user; Intent i = new Intent(this, Profile.class); startActivity(i); return true; } if (id == R.id.edit_profile) { Intent i = new Intent(this, Edit_profile.class); startActivity(i); return true; } if (id == R.id.to_feed) { Intent i = new Intent(this, Feed.class); startActivity(i); return true; } if (id == R.id.new_post) { Intent i = new Intent(this, New_post.class); startActivity(i); return true; } if (id == R.id.search) { Intent i = new Intent(this, Search.class); startActivity(i); return true; } if (id == R.id.log_out) { Session.Logout(); Intent i = new Intent(this, Welcome.class); startActivity(i); return true; } //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); }