Android : how to pass value from adapter class to fragment how actvity

on Thursday, September 25, 2014



public static String receiverId ;
public class Notifcationadapter extends BaseAdapter {

public static
DataBaseManager dbManager = new DataBaseManager(context);
ArrayList<Notify> notifies;

public Notifcationadapter(Context context, ArrayList<Notify> notifies) {
super();
this.context = context;
this.notifies = notifies;

}

/* private view holder class */
private class ViewHolder {

TextView txtTitle;
TextView txtDesc;
ImageView yesimage;

ImageView noimage;
TextView revresetime;

TextView rejected;
ImageView notificationuserimage;
RelativeLayout relativeLayout;
}

public View getView(int position, View convertView, ViewGroup parent) {

LayoutInflater mInflater = (LayoutInflater) context
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);


final DataBaseManager dbManager = new DataBaseManager(context);
final String isRead = notifies.get(position).getNotificationIsRead();
final String dateTime = notifies.get(position)
.getNotificationDatetime();
final String desc = notifies.get(position).getNotificationDescrpiton();
final String id = notifies.get(position).getNotificationId();
receiverId = notifies.get(position).getNotificationRecieverID();
((HomeActivity) context).NotifcationRecciverid = notifies.get(position)
.getNotificationRecieverID();
((HomeActivity) context).nOtifcationMessge = notifies.get(position)
.getNotificationDescrpiton();

final String senderId = notifies.get(position)
.getNotificationSenderID();
final String serverId = notifies.get(position)
.getNotificationServerId();
final String status = notifies.get(position).getNotificationStatus();
final String type = notifies.get(position).getNotificationType();
}
}


This is My code of Adapter class am able to get value from database of receiver id i want to pass this value to another actvity so that i can compare it but am getting null value when i pass to another :


am using like this :



String value =Notifcationadapter.receiverId;
markerOptions.title(datamodel.contactName);
if (datamodel.id
.equals(Notifcationadapter.receiverId)) {
markerOptions
.snippet(((HomeActivity) getActivity()).nOtifcationMessge);
map.addMarker(markerOptions).showInfoWindow();

} else {
markerOptions.snippet(datamodel.phoneNumber);
// Adding marker on the Google Map
map.addMarker(markerOptions);
}

}


this code am using to compare value but here am getting value null of receiver id please help suggest me where am doing wrong please tell me how i will pass value from one to another


0 comments:

Post a Comment