小编jsw*_*jsw的帖子

将数据从活动传递到对话框

我正在寻找一种方法将数据从活动传递到对话框.我试图打电话showDialog(int);,但是我没有看到将任何数据传递到对话框的方法.我需要将一个字符串传递给对话框以显示确认:)

干杯

android

9
推荐指数
1
解决办法
2万
查看次数

使用AsyncTask冻结UI线程

我正在尝试使用an AsyncTask来下载带有通知进度的文件.一切正常(在后台线程下载),除非我添加代码以更新进度条publishProgress(),它冻结整个手机,直到下载完成并且通知显示"下载完成".

我完全迷失了为什么会这样,但我可能会认为这与publishProgress((downloadedSize / totalSize) * 100)我正在使用的一致?

无论如何这里是DownloadDataTask:

    protected String doInBackground(RomDataSet... params) {
        try {

            // Download file here, all good

            //now, read through the input buffer and write the contents to the file
            while ( (bufferLength = inputStream.read(buffer)) > 0 ) {
                //add the data in the buffer to the file in the file output stream (the file on the sd card
                fileOutput.write(buffer, 0, bufferLength);
                //add up the size so we know …
Run Code Online (Sandbox Code Playgroud)

android

5
推荐指数
1
解决办法
2526
查看次数

将对象属性分配给listview

我有一个ArrayList具有属性的对象的Object.nameObject.url.

我想循环遍历ArrayList并将Object的"name"应用于android ListView.我还希望保持Object的其他属性,以便我可以在onClick方法中调用"url"属性.

我现在拥有的是:

main_list.setAdapter(new ArrayAdapter<RomDataSet>(this, android.R.layout.simple_list_item_1, android.R.id.text1, mRoms));
Run Code Online (Sandbox Code Playgroud)

但显然这不是我需要的......

任何帮助,将不胜感激 :)

android android-layout

4
推荐指数
1
解决办法
3032
查看次数

从外部类中的名称获取资源

我有一个字符串,用于标识我想要抓取的资源.

我知道以下内容:

public int getIdentifier(String name, String defType, String defPackage)
Run Code Online (Sandbox Code Playgroud)

但是我需要在外部类中使用它,它不会让我.

例如,我有一个名为"thefile"的字符串,我想访问R.raw.thefile

有任何想法吗?我被卡住了

干杯

android

2
推荐指数
1
解决办法
667
查看次数

标签 统计

android ×4

android-layout ×1