小编MAx*_*xeF的帖子

布局inflater中"附加到根"有什么用?

我是android的新手,我知道这个问题已被提出但我无法得到满意的解释.我的怀疑是:

  1. 什么是"附加到根",如果可能的话,用一个小而明确的例子.
  2. 当我搜索答案时,人们说其可选用于附加到父视图组,视图组层次结构是什么?(这是考虑我们以编程方式创建的视图还是考虑已经在xml文件中声明的视图)

我希望问题很清楚,如果不是,请在评论中说明.

android android-view

14
推荐指数
2
解决办法
6796
查看次数

使用DownloadManager时,ListView中的Android ProgressBar

我有一个ListView,其中每个项目代表一个PDF文件.当用户单击某个项目时,该应用程序必须在外部存储上下载该文件.现在下载无法正常运行,但这不是问题.我想要一个ProgressBar,旋转轮样式,在下载文件时出现在列表的每个项目旁边.

我的问题是:我找不到如何使纺车出现.在下载管理器之前,我尝试使用AsyncTask并且旋转轮工作.

这是我的代码:

CategoryActivity.java(ListView的活动)

@Override
public void onItemClick(AdapterView<?> parent, View view,
    int position, long id) {
    // Récupère les valeurs depuis ListItem
    udl = ((TextView) view.findViewById(R.id.udl)).getText().toString();
    // This is the spinning wheel
    loader = ((ProgressBar) view.findViewById(R.id.spinWheel2));

    filepath = dirpath + udl + ".pdf";
    File file = new File(filepath);
    if (file.exists()) {

        // If the file exists, I open it

    }else{ // Else I download it
        // Setting the spinning wheel to VISIBLE
        loader.setVisibility(View.VISIBLE);

        SharedPreferences codeSaveUrl = getSharedPreferences(PREFS_TEXT,Context.MODE_PRIVATE);
        url2 = codeSaveUrl.getString("defaut", …
Run Code Online (Sandbox Code Playgroud)

android download-manager android-listview android-progressbar android-download-manager

7
推荐指数
1
解决办法
4267
查看次数