This is my Custom Adapter. I have three ImageViews here. I wanted to give onclick for every imageview.
First I have called a method when click on ImageView. In that method I need to replace with the another image. And also need to replace remaining two Imageview images also.
Now When I click on first imageview, method is calling and image also changing for that. But for Remaining two Imageviews, It is showing NULL POINTER EXCEPTION.
How to access those ImageViews in that method.
Any help would be appreciated.
public class CustomTestingProductsListAdapter extends BaseAdapter{
public CustomTestingProductsListAdapter(Context context, Activity activity, List<V_APP_PACK_QR_DET_INFO> pack_qr_det_infos) {
layoutInFlater = LayoutInflater.from(context);
this.pack_qr_det_infos = pack_qr_det_infos;
this.curActivity = activity;
this.mContext = (VilanApplication) VilanApplication.mContext;
}
#Override
public int getCount() {
return pack_qr_det_infos.size();
}
#Override
public Object getItem(int position) {
return pack_qr_det_infos.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
try{
CustomTestingProductsListAdapter.ViewHolder holder;
if(convertView == null){
holder = new CustomTestingProductsListAdapter.ViewHolder();
convertView = layoutInFlater.inflate(R.layout.tst_ver_prdouct_list_items,null);
holder.tvProduct = convertView.findViewById(R.id.tv_qc_productName);
holder.DLSno = convertView.findViewById(R.id.tvtst_DLSno);
holder.iv_tst_received = convertView.findViewById(R.id.iv_tst_received);
holder.iv_tst_not_received = convertView.findViewById(R.id.iv_tst_not_received);
holder.iv_tst_wrong_product = convertView.findViewById(R.id.iv_tst_wrong_product);
convertView.setTag(holder);
}else{
holder = (CustomTestingProductsListAdapter.ViewHolder) convertView.getTag();
}
holder.DLSno.setText(pack_qr_det_infos.get(position).PRODUCTSLNO);
holder.iv_tst_received.setOnClickListener(onClickListener(position));
}catch (Exception e){
Log.d(VilanConstants.TAG,"/Excp #listAdp"+ e.toString());
}
return convertView;
}
private View.OnClickListener onClickListener(final int position){
return new View.OnClickListener() {
#Override
public void onClick(View v) {
try {
CustomTestingProductsListAdapter.ViewHolder holder;
holder = new CustomTestingProductsListAdapter.ViewHolder();
holder.iv_tst_received = v.findViewById(R.id.iv_tst_received);
holder.iv_tst_not_received = v.findViewById(R.id.iv_tst_not_received);
holder.iv_tst_wrong_product = v.findViewById(R.id.iv_tst_wrong_product);
Toast.makeText(mContext, "Item Received" , Toast.LENGTH_SHORT).show();
holder.iv_tst_received.setImageResource(R.drawable.ic_received_green);
holder.iv_tst_not_received.setImageResource(R.drawable.ic_not_received);
holder.iv_tst_wrong_product.setImageResource(R.drawable.ic_wrong_product);
Status = 0 ;
}catch (Exception e){
Log.e(VilanConstants.TAG,"/Excp due to"+e.toString());
}
}
};
}
public class ViewHolder{
private TextView tvProduct;
private TextView DLSno;
private ImageView iv_tst_received;
private ImageView iv_tst_not_received;
private ImageView iv_tst_wrong_product;
}
}
Update Your getView():
#Override
public View getView(int position, View convertView, ViewGroup parent) {
try{
CustomTestingProductsListAdapter.ViewHolder holder;
if(convertView == null){
holder = new CustomTestingProductsListAdapter.ViewHolder();
convertView = layoutInFlater.inflate(R.layout.tst_ver_prdouct_list_items,null);
holder.tvProduct = convertView.findViewById(R.id.tv_qc_productName);
holder.DLSno = convertView.findViewById(R.id.tvtst_DLSno);
holder.iv_tst_received = convertView.findViewById(R.id.iv_tst_received);
holder.iv_tst_not_received = convertView.findViewById(R.id.iv_tst_not_received);
holder.iv_tst_wrong_product = convertView.findViewById(R.id.iv_tst_wrong_product);
convertView.setTag(holder);
}else{
holder = (CustomTestingProductsListAdapter.ViewHolder) convertView.getTag();
}
holder.DLSno.setText(pack_qr_det_infos.get(position).PRODUCTSLNO);
holder.iv_tst_received.setOnClickListener(new View.OnClickListener(){
#Override
public void onClick(View v) {
Toast.makeText(mContext, "Item Received" , Toast.LENGTH_SHORT).show();
holder.iv_tst_received.setImageResource(R.drawable.ic_received_green);
holder.iv_tst_not_received.setImageResource(R.drawable.ic_not_received);
holder.iv_tst_wrong_product.setImageResource(R.drawable.ic_wrong_product);
Status = 0 ;
}
});
}catch (Exception e){
Log.d(VilanConstants.TAG,"/Excp #listAdp"+ e.toString());
}
return convertView;
}
Related
I am trying to display a ListView of some docs and images with different layouts.
it worked for docs but images are still not showing.
I have used the .contains method to check if the item is doc or image. Help me with this.
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater layoutInflater = activity.getLayoutInflater();
String fileName = uriList.get(position).getFileName();
return viewSetup(position, layoutInflater, fileName);
}
private View viewSetup(final int position, LayoutInflater layoutInflater, String fileName) {
if (fileName.contains(".png") || fileName.contains(".jpg") || fileName.contains(".jpeg")) {
View inflate = layoutInflater.inflate(R.layout.main_list_item_img, null, false);
ImageView imageView = inflate.findViewById(R.id.imgPrev);
Glide.with(activity).load(uriList.get(position).getDownloadLink()).into(imageView);
itemSetup(position, fileName, inflate);
return inflate;
} else {
View inflate = layoutInflater.inflate(R.layout.main_list_item_docs, null, false);
itemSetup(position, fileName, inflate);
return inflate;
}
}
private void itemSetup(final int position, String fileName, View inflate) {
TextView title = inflate.findViewById(R.id.uriTitle);
TextView desc = inflate.findViewById(R.id.uriDesc);
ImageView download = inflate.findViewById(R.id.download);
TextView createdOn = inflate.findViewById(R.id.createdOn);
title.setText(fileName + "");
desc.setText(uriList.get(position).getDescription());
createdOn.setText(uriList.get(position).getSendTime());
download.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
savefile(uriList.get(position).getDownloadLink());
}
});
}
I think there is a problem in your image loading. You can use Picasso.
Picasso.with(activity).load(yourUrl).
placeholder(R.drawable.image_loader).into(myImage);
You need to use type variable you can check how I did in below example :-
public class JobsAdapter extends BaseAdapter {
private Activity context;
private LinkedList<KeyValuesPair> listItemArrayList;
private LinkedList<Integer> type;
private LayoutInflater inflater;
public JobsAdapter(Activity context, LinkedList<KeyValuesPair> objects, LinkedList<Integer> type) {
this.context = context;
this.listItemArrayList = objects;
this.type = type;
inflater = LayoutInflater.from(context);
}
#Override
public int getCount() {
return type.size();
}
#Override
public Object getItem(int position) {
return position;
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public boolean isEnabled(int position) {
return type.get(position) != 0;
}
#TargetApi(Build.VERSION_CODES.O)
public View getView(int position, View convertView, ViewGroup parent) {
// used new view instead of convertView so the spinner could support multiple views
View view = null;
// if type is equals to 0 it will load jobs header else jobs child
if (type.get(position) == 0) {
view = inflater.inflate(R.layout.lv_header, null, false);
TextView header = view.findViewById(R.id.jobsHeading);
header.setText(listItemArrayList.get(position).getValue());
if (position == 0) {
header.setTextSize(16);
header.setTypeface(context.getResources().getFont(R.font.raleway_regular));
header.setTextColor(context.getResources().getColor(R.color.colorPrimaryDark));
} else {
header.setTextColor(context.getResources().getColor(R.color.colorBlack));
}
} else if (type.get(position) == 1) {
view = inflater.inflate(R.layout.lv_child, null, false);
TextView child = view.findViewById(R.id.jobsChild);
child.setText(listItemArrayList.get(position).getValue());
}
return view;
}
}
There is a custom listview which contains image and text. Am implemented click event on the image in the custom listview and it is working partially. Which means when the list loads when i click on it, i am able to see the image in dialog but when i scroll down and came up then when i try to click on the same image which i clicked earlier the click event is not working. I am not sure what is the reason for this behavior.
code:
public class DescAdapter extends BaseAdapter implements Filterable {
private final listdisplay ds;
private ArrayList<descusers> dusers;
private ArrayList<descusers> orig;
private Activity listdisplay;
PhotoViewAttacher p;
public DescAdapter(listdisplay ds, ArrayList<descusers> dusers,Activity listdisplay) {
this.ds = ds;
this.dusers = dusers;
this.listdisplay = listdisplay;
}
#Override
public int getCount() {
return dusers.size();
}
#Override
public Object getItem(int position) {
return dusers.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
descusers du = dusers.get(position);
String username = du.loginname;
String descCrip=du.descCrip;
final String Limage = du.image;
long Ptime = du.Ptime;
Viewholder viewholder = null;
if(convertView==null) {
viewholder = new Viewholder();
convertView = LayoutInflater.from(ds).inflate(R.layout.customlist, null);
viewholder.uname = (TextView) convertView.findViewById(R.id.username);
viewholder.desc = (TextView) convertView.findViewById(R.id.description);
viewholder.time = (TextView)convertView.findViewById(R.id.time);
viewholder.iview = (ImageView) convertView.findViewById(R.id.imageList);
convertView.setTag(viewholder);
}else {
viewholder = (Viewholder) convertView.getTag();
}
viewholder.uname.setText(username);
viewholder.desc.setText(descCrip);
if (Limage.trim().isEmpty()) {
viewholder.iview.setEnabled(false);
} else {
Glide.with(convertView.getContext()).load(Limage)
.diskCacheStrategy(DiskCacheStrategy.ALL).centerCrop().into(viewholder.iview);
}
return convertView;
}
Onclick code:
final Viewholder finalViewholder = viewholder;
viewholder.iview.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Dialog builder = new Dialog(listdisplay, android.R.style.Theme_DeviceDefault);
builder.requestWindowFeature(Window.FEATURE_NO_TITLE);
builder.getWindow().setBackgroundDrawable(
new ColorDrawable(Color.BLACK));
builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
#Override
public void onDismiss(DialogInterface dialogInterface) {
//nothing;
}
});
ImageView imageView = new ImageView(listdisplay);
// Glide.with(finalConvertView.getContext()).load(Limage)
// .diskCacheStrategy(DiskCacheStrategy.ALL).into(imageView);
final GlideBitmapDrawable bitmapDrawable = (GlideBitmapDrawable) finalViewholder.iview.getDrawable();
final Bitmap yourBitmap = bitmapDrawable.getBitmap();
imageView.setImageBitmap(yourBitmap);
p = new PhotoViewAttacher(imageView);
builder.addContentView(imageView, new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
builder.show();
}
});
I am using Glide library to load the image. I tried implement click listener inside the if(convertView == null) and outside as well. so where do i need to implement onclick inside adapter so that i will work?
Can anyone help me with figuring out why my listview repeats the results it gets from the database. I am using a Listview with Checkbox. Here is my code below.
public class AccessLevels extends Fragment {
MyAdminAdapter adminAdapter = null;
Guards guards;
ListView listView;
public ArrayList<Guards> guardsName;
public String str_name;
public boolean isAdmin;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_access_levels, container, false);
listView = (ListView)view.findViewById(R.id.list_of_guards);
return view;
}
private class MyAdminAdapter extends ArrayAdapter<Guards>{
private ArrayList<Guards> objectsList;
public MyAdminAdapter(Context context, int resource, ArrayList<Guards> objectsList) {
super(context, resource, objectsList);
this.objectsList = objectsList;
this.objectsList.addAll(objectsList);
}
private class ViewHolder{
CheckBox chk_name;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null){
LayoutInflater vi = (LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = vi.inflate(R.layout.single_row_access, null);
holder = new ViewHolder();
holder.chk_name = (CheckBox) convertView.findViewById(R.id.chk_guard);
convertView.setTag(holder);
}
else {
holder = (ViewHolder) convertView.getTag();
}
final Guards guards = objectsList.get(position);
holder.chk_name.setText(guards.getName());
holder.chk_name.setChecked(guards.isChecked());
holder.chk_name.setTag(guards);
holder.chk_name.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
CheckBox cb = (CheckBox) v;
Guards guards = (Guards) cb.getTag();
guards.setChecked(cb.isChecked());
}
});
return convertView;
}
}
#Override
public void onDestroy() {
super.onDestroy();
}
#Override
public void onDetach() {
super.onDetach();
}
}
I get the data an store it like this.
private void DisplayAllNames() {
guardsName = new ArrayList<Guards>();
ParseQuery<ParseObject> guardsQuery = ParseQuery.getQuery("Guards");
guardsQuery.whereExists("Name");
guardsQuery.orderByAscending("Name");
guardsQuery.findInBackground(new FindCallback<ParseObject>() {
#Override
public void done(List<ParseObject> list, ParseException e) {
if (e == null) {
if (list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
ParseObject data = list.get(i);
str_name = data.getString("Name");
isAdmin = data.getBoolean("admin");
guards = new Guards(str_name, isAdmin);
guardsName.add(guards);
}
adminAdapter = new MyAdminAdapter(getActivity(), R.layout.single_row_access, guardsName);
listView.setAdapter(adminAdapter);
} else {
}
} else {
}
}
});
}
Thanks in advance.
Remove this line from your MyAdminAdapter's constructor:
this.objectsList.addAll(objectsList);
You are already adding your items in the previous instruction:
this.objectsList = objectsList;
In your MyAdminAdapter you are adding the data twice:
this.objectsList = objectsList;
this.objectsList.addAll(objectsList);
You just have to remove the second line.
I am trying to create an android application using a database from Parse.com. I am using a custom adapter to create a listview. I don't find any errors with the code and yet the listeview is not showing up. Nothing there in the logcat as well. Just the listview does not show up.
lv = (ListView)findViewById(R.id.listView);
mProgress = (ProgressBar)findViewById(R.id.check_progress);
mProgress.setVisibility(View.VISIBLE);
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Sellers");
query.orderByAscending("Name");
query.findInBackground(new FindCallback<ParseObject>() {
#Override
public void done(List<ParseObject> parseObjects, ParseException e) {
if (e == null) {
studentsList = new ArrayList<Sellers>();
for (ParseObject ob : parseObjects) {
s = new Sellers();
s.setName(ob.getString("Name").toString());
s.setAddress1(ob.getString("Address1").toString());
s.setAddress2(ob.getString("Address2").toString());
s.setShopName(ob.getString("ShopName").toString());
s.setEmail(ob.getString("Email").toString());
s.setPhone(ob.getString("Phone").toString());
s.setZipcode(ob.getString("Zipcode").toString());
studentsList.add(s);
}
adapter = new ListviewAdapter(CheckStatus.this, studentsList);
lv.setAdapter(adapter);
mProgress.setVisibility(View.GONE);
} else {
mProgress.setVisibility(View.GONE);
Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
This is the activity where I am invoking the listview.
public class ListviewAdapter extends BaseAdapter{
private final static String TAG = ListviewAdapter.class.getSimpleName();
private Context activity;
private LayoutInflater inflater = null;
private List<Sellers> sellers;
int layout;
public ListviewAdapter(Context activity, List<Sellers> sellers) {
this.activity = activity;
this.sellers = sellers;
inflater = LayoutInflater.from(activity);
}
#Override
public int getCount() {
return 0;
}
#Override
public Object getItem(int position) {
return null;
}
#Override
public long getItemId(int position) {
return 0;
}
public class ViewHolder {
TextView name ;
TextView shop ;
TextView address1 ;
TextView address2;
TextView phone;
TextView email;
RelativeLayout rl;
}
#Override
public View getView(int position, View view, ViewGroup parent) {
View v =view;
ViewHolder holder = new ViewHolder();
if (view == null) {
LayoutInflater li = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = li.inflate(R.layout.list_item_layout,null);
holder.name = (TextView)v.findViewById(R.id.seller_name);
holder.shop = (TextView)v.findViewById(R.id.shop_name);
holder.address1 = (TextView)v.findViewById(R.id.address1);
holder.address2 = (TextView)v.findViewById(R.id.address2);
holder.phone = (TextView)v.findViewById(R.id.phone);
holder.email = (TextView)v.findViewById(R.id.emailID);
v.setTag(holder);
} else {
holder = (ViewHolder) v.getTag();
}
Sellers s = sellers.get(position);
// String a = s.Name;
// Log.d(TAG, a);
holder.name.setText(s.getName());
holder.shop.setText(s.getShopName());
holder.address1.setText(s.getAddress1());
holder.address2.setText(s.getAddress2());
holder.phone.setText(s.getPhone());
holder.email.setText(s.getEmail());
Log.d("CustomAdapter.class", "CustomAdapter");
// imageView.setImageDrawable(s.getPic());
return v;
}
}
And this is the custom adapter. There are no null pointer exceptions showing up in the logcat. I can't determine why the listview is not getting populated.
Try this;
#Override
public int getCount() {
return sellers.size();
}
#Override
public Object getItem(int position) {
return position;
}
#Override
public long getItemId(int position) {
return position:
}
You have to implement your code on getCount() by return number of item listview will be created.
Could anybody explain me, how to realize?
I have an activity with listview and footer with some elements(textview).
Listview built with custom adapter. Each listview item has few elements. And my question: how can i change textview in footer, from custom adapter, when i clicking on some listview's element?
Thx a lot!
/**** My adapter ****/
public class MyListAdapter extends ArrayAdapter<Product> implements UndoAdapter {
private final Context mContext;
private HashMap<Product, Integer> mIdMap = new HashMap<Product, Integer>();
ArrayList<Product> products = new ArrayList<Product>();
final int INVALID_ID = -1;
LayoutInflater lInflater;
String imagePath;
public MyListAdapter(Context context, int textViewResourceId, List<Product> prod) {
//super(context, textViewResourceId, prod);
super(prod);
lInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mContext = context;
for (int i = 0; i < prod.size(); i++) {
//add(prod.get(i));
mIdMap.put(prod.get(i),i);
}
}
#Override
public long getItemId(final int position) {
//return getItem(position).hashCode();
Product item = (Product) getItem(position);
return mIdMap.get(item);
}
#Override
public boolean hasStableIds() {
return true;
}
#Override
public View getView(final int position, View convertView, final ViewGroup parent) {
ViewHolder holder = null;;
Product p = getItem(position);
if (convertView == null) {
convertView = lInflater.inflate(R.layout.item, null);
//convertView.setBackgroundResource(R.drawable.rounded_corners);
int currentTheme = Utils.getCurrentTheme(convertView.getContext());
switch (currentTheme) {
case 0:
convertView.setBackgroundResource(R.drawable.rounded_corners);
break;
case 1:
convertView.setBackgroundResource(R.drawable.border);
break;
default:
convertView.setBackgroundResource(R.drawable.rounded_corners);
break;
}
holder = new ViewHolder();
holder.tvDescr = (TextView) convertView.findViewById(R.id.tvDescr);
holder.list_image = (ImageView) convertView.findViewById(R.id.list_image);
holder.products_amount = (TextView) convertView.findViewById(R.id.amountDigits);
holder.products_price = (TextView) convertView.findViewById(R.id.priceDigits);
holder.ivImage = (ImageView) convertView.findViewById(R.id.ivImage);
holder.unit = (TextView) convertView.findViewById(R.id.unit);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
if(p.getProductImageBitmap() != null && p.getProductImageBitmap() != "") {
Log.d("PATH -- ", p.getProductImageBitmap());
ImageLoader imageLoader = ImageLoader.getInstance();
DisplayImageOptions options = new DisplayImageOptions.Builder().cacheInMemory(true)
.resetViewBeforeLoading(true)
.showImageForEmptyUri(R.drawable.ic_launcher)
.showImageOnFail(R.drawable.ic_launcher)
/*.showImageOnLoading(R.id.progress_circular)*/
.build();
imageLoader.displayImage(p.getProductImageBitmap(), holder.list_image, options);
} else {
holder.list_image.setImageResource(R.drawable.ic_launcher);
}
holder.tvDescr.setText(p.getProductName());
holder.ivImage.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
String deletedItem = getItem(position).getProductName();
MyListAdapter.this.remove(getItem(position));
if (MyListAdapter.this.getCount() > 0) {
Toast.makeText(mContext, deletedItem + " " + mContext.getString(R.string.deleted_item), Toast.LENGTH_SHORT).show();
MyListAdapter.this.notifyDataSetChanged();
} else {
Toast.makeText(mContext,mContext.getString(R.string.sklerolist_empty), Toast.LENGTH_SHORT).show();
}
}
});
//Функционал для большой картинки продукта
//открывается новое активити с большой картинкой
holder.list_image.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
imagePath = getItem(position).getProductImageBitmap();
if(imagePath != null && imagePath != "") {
Pattern normalPrice = Pattern.compile("^file");
Matcher m2 = normalPrice.matcher(imagePath);
if (m2.find()) {
Intent myIntent = new Intent(view.getContext(), ViewImage.class).putExtra("imagePath", imagePath);
view.getContext().startActivity(myIntent);
}
}
}
});
holder.products_price.setText(fmt(p.getProductPrice()));
holder.products_amount.setText(fmt(p.getProductAmount()));
holder.unit.setText(p.getProductUnit());
return convertView;
}
public static String fmt(double d){
if(d == (long) d)
return String.format("%d",(long)d);
else
return String.format("%s",d);
}
static class ViewHolder {
ImageView list_image;
TextView tvDescr;
TextView products_amount;
TextView products_price;
TextView unit;
ImageView ivImage;
ProgressBar circleProgress;
}
#NonNull
#Override
public View getUndoView(final int position, final View convertView, #NonNull final ViewGroup parent) {
View view = convertView;
if (view == null) {
//view = LayoutInflater.from(mContext).inflate(R.layout.undo_row, parent, false);
view = lInflater.inflate(R.layout.undo_row, parent, false);
}
return view;
}
#NonNull
#Override
public View getUndoClickView(#NonNull final View view) {
return view.findViewById(R.id.undo_row_undobutton);
}
public View getHeaderView(final int position, final View convertView, final ViewGroup parent) {
TextView view = (TextView) convertView;
//View view = convertView;
if (view == null) {
//view = (TextView) LayoutInflater.from(mContext).inflate(R.layout.list_header, parent, false);
//view = lInflater.inflate(R.layout.list_header, parent, false);
}
//view.setText(mContext.getString(R.string.header, getHeaderId(position)));
return view;
}
public long getHeaderId(final int position) {
return position / 10;
}
}
Your ListView has a listener for the click events on list elements.
#Override
public void onListItemClick(ListView l, View v, int position, long id) {
// Do something when a list item is clicked
}
But if you want to pas something else back from the adapter to the Activity or the Fragment that contains that ListView and Adapter, you should create a simple interface and set it as listener to your adapter. After that, set click events on your rows from within the adapter, and notify the Activity or Fragment using your own interface.
For example you have the interface defined like this
public interface OnItemClickedCustomAdapter {
public void onClick(ItemPosition position);
}
and in your Adapter class you will have a private member
private OnItemClickedCustomAdapter mListener;
and a method used to set the listener
public void setOnItemClickedCustomAdapter(OnItemClickedCustomAdapter listener){
this.mListener = listener;
}
From your Activity or Fragment where your ListView is defined, and your adapter is set, you will be able to call setOnItemClickedCustomAdapter with this as parameter, and there you go. Your activity will now listen for your events. To trigger an event, just call mListener.onClick() from your custom adapter. You can pass back data you need back to the Activity or Fragment, and from there you have access to your Header or Footer directly, and you can change the text on them.