} catch (IOException e) {
Log.i("DisplayFriendActivity", "Couldn't fetch friends from the " +
"container: " + e.getMessage());
}
LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT));
linearLayout.setOrientation(LinearLayout.VERTICAL);
if (friends != null && friends.size() > 0) {
FriendListView contactsView = new FriendListView(this);
contactsView.setFriends(friends);
contactsView.setVerticalScrollBarEnabled(true);
contactsView.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, 300));
linearLayout.addView(contactsView);
} else {
TextView textView = new TextView(this);
textView.setText("No contacts found.");
linearLayout.addView(textView);
}
final FriendListActivity activity = this;
Button clearAuthButton = new Button(this);
clearAuthButton.setText("Clear Auth");
clearAuthButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
clearSavedAuthentication();
}
});
Button fetchFriendsButton = new Button(this);
fetchFriendsButton.setText("Fetch Friends");
fetchFriendsButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
activity.setupClient();
}
});
linearLayout.addView(fetchFriendsButton);
linearLayout.addView(clearAuthButton);
setContentView(linearLayout);
}