Android将文本文件读入对话框 [英] Android Read Text File Into Dialog

查看:60
本文介绍了Android将文本文件读入对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!



是否可以从资产/原始文件夹中将文本文件读入警报对话框构建器



AlertDialog.Builder alertDialogBu​​ilder = new AlertDialog.Builder(

KneelingDown.this);



//设置标题

alertDialogBu​​ilder.setTitle(我的标题);

alertDialogBu​​ilder.setIcon(R.mipmap.ic_launcher);

//设置对话框消息

alertDialogBu​​ilder

.setMessage(从资源/原始文件夹中读取文本文件)

.setCancelable(false)

.setPositiveButton(Cancel,new DialogInterface.OnClickListener(){

public void onClick(DialogInterface dialog,int id){

//如果这个按钮点击,关闭

//当前活动



}

});



//创建提醒对话框

AlertDia log alertDialog = alertDialogBu​​ilder.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆