如何从适配器向其自己的活动发送字符串数组列表

问题描述 投票:0回答:2

我正在申请考勤系统,想进入考勤。所有学生列表都显示在listview中,并且逐个元素想要存储在listview适配器中的arraylist中并将其发送到自己的活动以在数据库中存储arraylist

android
2个回答
1
投票

1: - 通过使用界面

public interface ICallback { void onViewClick(ArrayList<String> mList); }

2: - 通过在该活动上创建一个以列表作为参数的公共方法。

public void onViewClick(ArrayList<String> mList){ // do your task here }

0
投票

**使用公共方法**

public void notifyMainAdapter(){

adapterName.notifyDataSetChanged();

}

然后在适配器中调用此方法

public void parentLIstUpdate(){

new MainActivity.notifyMainAdapter(); }

© www.soinside.com 2019 - 2024. All rights reserved.