I am in the following situation:
- I have the default implementation of the navigation drawer from Android Studio with a navigationDrawerFragment.
- I have a custom listView for this navigationDrawerFragment with a custom adapter.
- Since I have different type of item in my listView, i use the classic holder pattern.
My problem is the following: I'd like to send data from my container activity (facebook profile picture and name) to the custom adapter to set the holder with these data.
how can I do that ? See the following code:
if (view == null) {
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
drawerHolder = new DrawerItemHolder();
view = inflater.inflate(layoutResID, parent, false);
drawerHolder.ItemName = (TextView) view
.findViewById(R.id.drawer_profileName);
drawerHolder.icon = (ProfilePictureView) view.findViewById(R.id.drawer_profileIcon);
drawerHolder.title = (TextView) view.findViewById(R.id.drawer_titleName);
drawerHolder.item = (TextView) view.findViewById(R.id.drawer_itemName);
drawerHolder.logOut = (TextView) view.findViewById(R.id.drawer_logOut);
drawerHolder.logOut.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onLogoutButtonClicked();
}
});
drawerHolder.titleLayout = (LinearLayout) view.findViewById(R.id.titleLayout);
drawerHolder.itemLayout = (LinearLayout) view.findViewById(R.id.itemLayout);
drawerHolder.profileLayout = (LinearLayout) view.findViewById(R.id.profileLayout);
view.setTag(drawerHolder);
} else {
drawerHolder = (DrawerItemHolder) view.getTag();
}
DrawerItem dItem = (DrawerItem) this.drawerItemList.get(position);
if (dItem.isTitle()){
drawerHolder.titleLayout.setVisibility(LinearLayout.VISIBLE);
drawerHolder.itemLayout.setVisibility(LinearLayout.INVISIBLE);
drawerHolder.profileLayout.setVisibility(LinearLayout.INVISIBLE);
drawerHolder.title.setText(dItem.getTitle());
} else if (dItem.getImgResID() == 0) {
drawerHolder.titleLayout.setVisibility(LinearLayout.INVISIBLE);
drawerHolder.itemLayout.setVisibility(LinearLayout.VISIBLE);
drawerHolder.profileLayout.setVisibility(LinearLayout.INVISIBLE);
drawerHolder.item.setText(dItem.getItem());
} else {
drawerHolder.titleLayout.setVisibility(LinearLayout.INVISIBLE);
drawerHolder.itemLayout.setVisibility(LinearLayout.INVISIBLE);
drawerHolder.profileLayout.setVisibility(LinearLayout.VISIBLE);
}
return view;
}
I need in the else to set the data I passed to the custom adapter to the facebookProfilPicture.