在ListView中检测外部文件

时间:2019-01-22 21:10:16

标签: android android-studio listview

我正在使用列表视图填充可下载的讲座列表(368个讲座)。

对于无法离线使用的讲座,它会显示“下载”文本。

  

对于可用的讲座,我正在进行外部文件检查,然后更新   “下载”到“脱机”的文本,但在ListView中无法正常工作   和值在重复。

这是我的getView方法代码

121 INFO: PyInstaller: 3.4
121 INFO: Python: 3.6.8
122 INFO: Platform: Windows-10-10.0.16299-SP0
130 INFO: wrote C:\Users\MadanR\Desktop\Python Executables\Test\test.spec
136 INFO: UPX is not available.
153 INFO: Extending PYTHONPATH with paths
['C:\\Users\\MadanR\\Desktop\\Python '
 'Executables\\Test',
 'C:\\Users\\MadanR\\Desktop\\Python '
 'Executables\\Test']
158 INFO: checking Analysis
161 INFO: Building Analysis because Analysis-00.toc is non existent
165 INFO: Initializing module dependency graph...
172 INFO: Initializing module graph hooks...
178 INFO: Analyzing base_library.zip ...
8026 INFO: running Analysis Analysis-00.toc
8031 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\users\madanr\appdata\local\continuum\anaconda3\envs\pyin36\python.exe
10193 INFO: Caching module hooks...
10216 INFO: Analyzing C:\Users\MadanR\Desktop\Python Executables\Test\test.py
10346 INFO: Processing pre-find module path hook   distutils
11180 INFO: Processing pre-safe import module hook   six.moves
17163 INFO: Processing pre-find module path hook   site
17164 INFO: site: retargeting to fake-dir 'c:\\users\\madanr\\appdata\\local\\continuum\\anaconda3\\envs\\pyin36\\lib\\site-packages\\PyInstaller\\fake-modules'
20521 INFO: Processing pre-safe import module hook   setuptools.extern.six.moves
39249 INFO: Loading module hooks...
39250 INFO: Loading module hook "hook-distutils.py"...
39268 INFO: Loading module hook "hook-encodings.py"...
39567 INFO: Loading module hook "hook-lib2to3.py"...
39584 INFO: Loading module hook "hook-numpy.core.py"...
39884 INFO: Loading module hook "hook-numpy.py"...
39895 INFO: Loading module hook "hook-pandas.py"...
41840 INFO: Loading module hook "hook-pkg_resources.py"...
42584 INFO: Processing pre-safe import module hook   win32com
42977 INFO: Loading module hook "hook-pydoc.py"...
42980 INFO: Loading module hook "hook-pythoncom.py"...
43610 INFO: Loading module hook "hook-pytz.py"...
43816 INFO: Loading module hook "hook-pywintypes.py"...
44355 INFO: Loading module hook "hook-scipy.linalg.py"...
44364 INFO: Loading module hook "hook-scipy.py"...
44382 INFO: Loading module hook "hook-scipy.sparse.csgraph.py"...
44395 INFO: Loading module hook "hook-scipy.special._ellip_harm_2.py"...
44397 INFO: Loading module hook "hook-scipy.special._ufuncs.py"...
44406 INFO: Loading module hook "hook-setuptools.py"...
45322 INFO: Loading module hook "hook-sqlite3.py"...
45543 INFO: Loading module hook "hook-sysconfig.py"...
45547 INFO: Loading module hook "hook-win32com.py"...
46118 INFO: Loading module hook "hook-xml.dom.domreg.py"...
46121 INFO: Loading module hook "hook-xml.py"...
46266 INFO: Looking for ctypes DLLs
46332 INFO: Analyzing run-time hooks ...
46348 INFO: Including run-time hook 'pyi_rth_pkgres.py'
46350 INFO: Including run-time hook 'pyi_rth_win32comgenpy.py'
46357 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
46396 INFO: Looking for dynamic libraries
72892 INFO: Looking for eggs
72892 INFO: Using Python library c:\users\madanr\appdata\local\continuum\anaconda3\envs\pyin36\python36.dll
72899 INFO: Found binding redirects:
[]
72948 INFO: Warnings written to C:\Users\MadanR\Desktop\Python Executables\Test\build\test\warn-test.txt
73287 INFO: Graph cross-reference written to C:\Users\MadanRDesktop\Python Executables\Test\build\test\xref-test.html
73433 INFO: checking PYZ
73433 INFO: Building PYZ because PYZ-00.toc is non existent
73439 INFO: Building PYZ (ZlibArchive) C:\Users\MadanR\Desktop\Python Executables\Test\build\test\PYZ-00.pyz
77493 INFO: Building PYZ (ZlibArchive) C:\Users\MadanR\Desktop\Python Executables\Test\build\test\PYZ-00.pyz completed successfully.
77615 INFO: checking PKG
77616 INFO: Building PKG because PKG-00.toc is non existent
77622 INFO: Building PKG (CArchive) PKG-00.pkg
77794 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
77810 INFO: Bootloader c:\users\madanr\appdata\local\continuum\anaconda3\envs\pyin36\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
77811 INFO: checking EXE
77812 INFO: Building EXE because EXE-00.toc is non existent
77815 INFO: Building EXE from EXE-00.toc
77817 INFO: Appending archive to EXE C:\Users\MadanRDesktop\Python Executables\Test\build\test\test.exe
77921 INFO: Building EXE from EXE-00.toc completed successfully.
77945 INFO: checking COLLECT
77945 INFO: Building COLLECT because COLLECT-00.toc is non existent
77961 INFO: Building COLLECT COLLECT-00.toc
97895 INFO: Building COLLECT COLLECT-00.toc completed successfully.

这是我的输出:

Screenshot of ListView

ListView (Continued)

1 个答案:

答案 0 :(得分:0)

Android回收视图。发生这种情况时,开发人员必须注意不要从回收的角度进行垃圾处理。

convertView中的getView()参数不为空时,它可能具有先前设置的值。在这种情况下,必须先清除它们,然后再显示视图,否则将显示垃圾。通常,您应该始终为getView()中的每个视图设置值。

例如,您可以执行以下操作:

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    // ...

    if (externalFile.exists()) {
        download_text.setText("Available");
    } else {
        // Set any text you want to show,
        // or just clear the view like this.
        download_text.setText("");
    }

    return view;
}