我用 textView 制作了 expandablelistview 并在子组中切换。我想使用开关的状态(开或关)来控制连接到 ESP8266 WiFi 模块的设备。如何存储交换机数据以在其他地方使用?
适配器java文件:
public class AdpMain extends BaseExpandableListAdapter {
private Context context;
private ArrayList<String> arrayGroup;
private HashMap<String, ArrayList<String>> arrayChild;
public AdpMain(Context context, ArrayList<String> arrayGroup, HashMap<String, ArrayList<String>> arrayChild)
{
super();
this.context = context;
this.arrayGroup = arrayGroup;
this.arrayChild = arrayChild;
}
...
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent)
{
String childName = arrayChild.get(arrayGroup.get(groupPosition)).get(childPosition);
View v = convertView;
if(v == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = (RelativeLayout)inflater.inflate(R.layout.activity_listview_child, null);
}
TextView textChild = (TextView)v.findViewById(R.id.textChild);
textChild.setText(childName);
return v;
}
}
