如何使用 sax 解析器在 android 中显示动态文本视图?
您好,我创建了一个网格视图应用程序。它在我的网格视图中显示我的 SD 卡图像,现在我只有 10 个图像。如果我在网格视图中单击第一张图像,我想使用文本视图显示一个段落。然后我单击第二张图像,我想显示另一段......所以我创建一个 xml 文件,该 xml 文件有 10 段。我的疑问如何显示这一段?当我单击该 gridview 图像时,我希望显示该图像,仅此而已......
<paragraph>
<par1>
dkdkkddkdkkdkkdkdkkdkdkdkdkdkdkdk]
dkdkkdkdkdkdkkdkdkdkdkdkdkdkdk
</par1>
<par2>
skjdkjfidfdjfkdjfoiudifjieiiejriej
dkiekdikdididkdkdkipppw;wpp;eokkll
</par2>
.
.
.
.
.
<par10>
dkdi;;iathehe thid tihoodfjalkjfkjdfk
dkjfldkjflkjdalkjldkjoaiuidfiudofuoia
</par10>
</paragraph>
这是我的示例 xml 文件,我希望仅解析 sax 解析。我很困惑请帮助我......
Hi I created one grid view application. it's display my sdcard images in my grid view, now I have 10 images only. if I click my 1st image in grid view I want to show one paragraph using text view. then i click 2nd images i want to show another one paragraph....so i create one xml file, the xml file have 10 paragraph. my doubt how to show this paragraph? when i click that gridview images i wish to show this images that's all....
<paragraph>
<par1>
dkdkkddkdkkdkkdkdkkdkdkdkdkdkdkdk]
dkdkkdkdkdkdkkdkdkdkdkdkdkdkdk
</par1>
<par2>
skjdkjfidfdjfkdjfoiudifjieiiejriej
dkiekdikdididkdkdkipppw;wpp;eokkll
</par2>
.
.
.
.
.
<par10>
dkdi;;iathehe thid tihoodfjalkjfkjdfk
dkjfldkjflkjdalkjldkjoaiuidfiudofuoia
</par10>
</paragraph>
This is my example xml file i wish to parse only sax parse only. I am confused please help me........
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您必须解析 xml 并将所有段落数据存储到数组或 Arralist 中。
编写Gridview的onItemclickListener事件,并在grid的onItemClickListener中显示自定义对话框。
在自定义对话框中,您必须使用文本视图设置一个 xml 文件。
此外,您还必须在 onItemclickListener 中设置该 TextView 的值。
您必须借助侦听器的索引参数来获取数据。
First of all you have to parse your xml and store all the paragraph data into array or arralist.
Write the onItemclickListener event of Gridview and display the Custom dialog in grid's onItemClickListener.
In Custom dialog, you have to set one xml file with textview.
Also, you have to set the value of that TextView in onItemclickListener.
You have to get the data with the help of the the index argument of the listener.
创建如下的 xml 结构:
然后将这些字符串解析为数组列表,并根据图像的选择位置,显示索引中的段落。
Create your xml structure as below:
Then Parse these strings into an arraylist, and according to the selection position of image, display paragraph from index.