我必须将现有的html文件加载到WebView位于文件系统中此路径的文件中:
/data/data/com.example.example/files/file.html
Run Code Online (Sandbox Code Playgroud)
但是,当WebView加载它时,我什么都看不到.谁能帮我?
WebView 代码(假设路径是我上面写的路径):
WebView webView = (WebView)findViewById(R.id.webView1);
File htmlFile = new File(path);
if(htmlFile.exists())
{
webView.loadUrl(htmlFile.getAbsolutePath());
}
Run Code Online (Sandbox Code Playgroud) 我想使用GridView并根据文档,在适配器中我可以在适配器中使用此行:
imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
Run Code Online (Sandbox Code Playgroud)
好吧,把它转换成Kotlin,它说:
它适用于Java,但不适用于Kotlin.
那么,为什么呢?我如何GridView.LayoutParams在Kotlin中使用?
我写了一个简单的代码块存储fragments与ids在Map.在value与key地图的初始化为不可为空的,但是当我想要让他们为key和value,它给nullable输入数据.所以,我不明白为什么?是否还有其他类型的地图可以返回non-nullable数据Kotlin?
以前我使用的是这段代码:
private val mItems = ArrayList<Int>()
(1..item_count).mapTo(mItems) { it }
/*
mItems will be: "1, 2, 3, 4, 5, ..., item_count"
*/
Run Code Online (Sandbox Code Playgroud)
现在,我使用的是一个类而不是Int,但该类具有Int名称的成员id.
class ModelClass(var id: Int = 0, var status: String = "smth")
Run Code Online (Sandbox Code Playgroud)
那么我如何使用这种方法以ArrayList类似的方式填充?
//?
private val mItems = ArrayList<ModelClass>()
(1..item_count).mapTo(mItems) { mItems[position].id = it } // Something like this
//?
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,用户可以从相机和图库中选择图像以加载到ImageView中。
我正在使用以下代码打开相关的应用程序以选择图像:
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
Run Code Online (Sandbox Code Playgroud)
问题出在Google硬盘上。如果用户从Google云端硬盘中选择图片,则我将获得这样的URI:content://com.google.android.apps.docs.storage.legacy/enc%3DHxtpLaMr66OMOzDOKTRZ-5ed7q7Szj7F7nC0IlxBnV8hx2P1%0A
我能够生成位图,但无法获取文件名。
InputStream input = context.getContentResolver().openInputStream(uri);
Bitmap bitmap = BitmapFactory
.decodeStream(input);
Run Code Online (Sandbox Code Playgroud)
我需要显示用户选择的文件名。
请帮我从Google驱动器URI中提取图片名称。
android android-imageview google-drive-api android-bitmap google-drive-android-api