I Have a listview of notification. and i want that after clicking on that notification it should be deleted.
but it gives me error of unsupported exception.If any one have solution please answer.
here, is my code.
NotificationSetGet notifisetget;
ArrayList<NotificationSetGet> clsdtlsetget;
NotificationAdapter notifiadp = new NotificationAdapter(clsdtlsetget,
getActivity());
lstview.setAdapter(notifiadp);
lstview.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent,
View view, int position, long id) {
// TODO Auto-generated method stub
notifisetget = clsdtlsetget.get(position);
clsdtlsetget.remove(position);
notifiadp.notifyDataSetChanged();
}
});
and here is my adapter.
public class NotificationAdapter extends BaseAdapter {
private final LayoutInflater mInflater;
ArrayList<NotificationSetGet> clsdtlsetget;
NotificationSetGet notifisetget;
Context mcontext;
String notititle, currentDateandTime, noticreateddatetime, notitype;
ListView mListView;
public NotificationAdapter(ArrayList<NotificationSetGet> clsdtlsetget,
Context context) {
this.mcontext = context;
mInflater = LayoutInflater.from(context);
this.clsdtlsetget = clsdtlsetget;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return 10;
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return clsdtlsetget.get(position);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(final int position, View convertView,
final ViewGroup parent) {
// TODO Auto-generated method stub
if (convertView == null) {
convertView = mInflater.inflate(R.layout.notificationraw,
parent, false);
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
currentDateandTime = sdf.format(new Date());
TextView textnotiftitle = (TextView) convertView
.findViewById(R.id.textnotiftitle);
TextView txtnotificationtime = (TextView) convertView
.findViewById(R.id.txtnotificationtime);
notifisetget = clsdtlsetget.get(position);
notititle = notifisetget.getNotification_text();
notitype = notifisetget.getnotificationType();
if (!TextUtils.isEmpty(notititle)) {
textnotiftitle.setText(notititle);
}
noticreateddatetime = notifisetget.getNotification_createdAt();
return convertView;
}
}