选择txt文件并将其加载到android应用程序(Delphi-XE5) [英] Select and load txt file to android application (Delphi-XE5)

查看:57
本文介绍了选择txt文件并将其加载到android应用程序(Delphi-XE5)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想浏览SD卡,选择目录和文件,然后将txt文件加载到由Delphi XE5创建的Android应用程序中.

I would like to browse SD card, select dir and file and load txt file to my Android application created by Delphi XE5.

是否有任何标准组件或方法?像OpedFileDialog吗?

Is any standart component or methods for this ? Like OpedFileDialog ?

推荐答案

在Android上没有等效的 TOpenFileDialog .它不是操作系统的一部分,并且在定位Android时无法从组件面板"中获得.

There is no equivalent for TOpenFileDialog on Android. It's not part of the operating system, and is not available from the Component Palette when targeting Android.

您可以通过在设计器中查看表单,然后在组件面板"中检查对话框选项卡来查看.所有组件均被禁用,这意味着它们不适用于目标平台.将鼠标悬停在任何一个上都表示它们可用于Win32,Win64和OS X,但不适用于iOS或Android.

You can see this by viewing the form in the designer, and then checking the Dialogs tab in the Component Palette; all of the components are disabled, meaning they're not available for the targeted platform. Hovering the mouse over any of them indicates they're available for Win32, Win64, and OS X, but not iOS or Android.

您始终可以基于 TForm (或者更好的是 TPopup )构建自己的模型,它更适合于移动设备的典型应用程序流程),使用 IOUtils.TPath 中可用的功能来检索目录和文件名.有了文件名后,加载文件的功能就很简单,并且可以通过多种方式使用-以下是其中几种:

You could always build your own, based on a TForm (or better yet, a TPopup, which is a better fit for the typical application flow for a mobile device), using the functionality available in IOUtils.TPath for retrieving directories and filenames. Once you have the filename, the functionality of loading it is simple and available in several ways - here are a few:

  • 使用 TFile.ReadAllLines (同样是 IOUtils )加载它
  • TStringList.LoadFromFile
  • 使用 TFileStream.LoadFromFile
  • 使用 TMemo.Lines.LoadFromFile
  • Load it using TFile.ReadAllLines (again from IOUtils)
  • TStringList.LoadFromFile
  • Using TFileStream.LoadFromFile
  • Using a TMemo.Lines.LoadFromFile

这篇关于选择txt文件并将其加载到android应用程序(Delphi-XE5)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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