简体   繁体   中英

refresh activity from listadapter onclicklistener in android app

I have an activity with a listview in it. I implemented a custom list adapter based on ArrayAdapter. Some of the items within the list are clickable and some are not. So I implemented the onClickListener within the getView method of the listadapter.

I can refresh the listview just fine by calling the notifyDataSetChanged() method.

What I want to do is refresh the textview within the activity which contains the list whenever an item in the list is clicked. I can't think of a way to do this. Anybody have any suggestions?

This is what the activity contains:

  1. TextView (Title)
  2. TextView (total points) -> I want to update this
  3. ListView (some items in the list are clickable)

Take the reference of the TextView inside your CustomListAdapter, then trigger the update of the total points textview inside your onClickListener.

pseudo

getView() {
    onClickListener(Event..) {
      pointsTextView.setText(..points+1..)
    }

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM