我有两个清单。一个是文件列表,另一个是文件夹列表。
list1[file1,file2,file3,file4]
list2[folder1,folder2]
我想搬家:
答案 0 :(得分:1)
现在是使用// Set Spinner's onItemSelectedListener ie to act when an aisle is selected.
// Note!!! run on post, as a runnable, so that initial onItemSelected event (at initialisation) is not captured.
current_aislelistspinner.post(new Runnable() {
@Override
public void run() {
current_aislelistspinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
currentaislelistcursor.moveToPosition(position);
currentaisleid = currentaislelistcursor.getLong(ShopperDBHelper.AISLES_COLUMN_ID_INDEX);
Log.d(Constants.LOG,"ACTIVITY: " + THIS_ACTIVITY + " SECTION: Running - AISLELIST OnItemSelectedLIstener" +
"- AILSEID Extracted=" + currentaisleid);
currentproductsperaisleecursor = shopperdb.getProductsperAisle(currentaisleid);
current_productsperaislecursoradapter.swapCursor(currentproductsperaisleecursor);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
});
内置库的好时机!
itertools
这只是循环的代码。移动文件应该很容易。查看import itertools
files = ["file1","file2","file3","file4"]
folders = ["folder1","folder2"]
for file, folder in zip(files, itertools.cycle(folders)):
print("move {} to {}".format(file, folder))
模块。
如果您有任何问题,请随时询问。