简体   繁体   English

从Android应用程序中的listadapter onclicklistener刷新活动

[英]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. 我实现了一个基于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. 因此,我在listadapter的getView方法中实现了onClickListener。

I can refresh the listview just fine by calling the notifyDataSetChanged() method. 我可以通过调用notifyDataSetChanged()方法来刷新列表视图。

What I want to do is refresh the textview within the activity which contains the list whenever an item in the list is clicked. 我想要做的是每当单击列表中的项目时刷新包含列表的活动内的textview。 I can't think of a way to do this. 我想不出办法。 Anybody have any suggestions? 有人有什么建议吗?

This is what the activity contains: 这是活动包含的内容:

  1. TextView (Title) TextView(标题)
  2. TextView (total points) -> I want to update this TextView(总点数)->我要更新
  3. ListView (some items in the list are clickable) ListView(列表中的某些项目是可单击的)

Take the reference of the TextView inside your CustomListAdapter, then trigger the update of the total points textview inside your onClickListener. 在CustomListAdapter中获取TextView的引用,然后在onClickListener中触发总点textview的更新。

pseudo 伪的

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

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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