Android将文本文件读入对话框 [英] Android Read Text File Into Dialog
问题描述
大家好!
是否可以从资产/原始文件夹中将文本文件读入警报对话框构建器
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
KneelingDown.this);
//设置标题
alertDialogBuilder.setTitle(我的标题);
alertDialogBuilder.setIcon(R.mipmap.ic_launcher);
//设置对话框消息
alertDialogBuilder
.setMessage(从资源/原始文件夹中读取文本文件)
.setCancelable(false)
.setPositiveButton(Cancel,new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int id){
//如果这个按钮点击,关闭
//当前活动
}
});
//创建提醒对话框
AlertDia log alertDialog = alertDialogBuilder.create();
//显示
alertDialog.show();
请帮助
Hi everyone in the house
Is it possible to read text files into an alert dialog builder from assets/raw folder
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
KneelingDown.this);
// set title
alertDialogBuilder.setTitle("My Title");
alertDialogBuilder.setIcon(R.mipmap.ic_launcher);
// set dialog message
alertDialogBuilder
.setMessage("Read text files from assets/raw folder in here ")
.setCancelable(false)
.setPositiveButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// if this button is clicked, close
// current activity
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
Kindly help
推荐答案
参见 http://developer.android.com/reference/android/content/res/AssetManager.html [ ^ ]。获得文件后,读取数据非常简单。
See http://developer.android.com/reference/android/content/res/AssetManager.html[^] for getting access to a resource in the assets folder. Once you have the file then reading the data is straightforward.
这篇关于Android将文本文件读入对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!