如何实现在Android中按字母顺序分离GridView的? [英] How do I implement an alphabetically separated GridView in Android?

查看:378
本文介绍了如何实现在Android中按字母顺序分离GridView的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用一个GridView来显示由按字母顺序排分隔的数据。网格视图中的每一行应该包含多达四个名字,应该只有开始连续相同字母的名字。我知道如何建立一个GridView,只是没有如何设置它在这种格式。下面的截图显示,我想做些什么:

I want to use a GridView to display data that is separated alphabetically by row. Each row of the grid view should contain up to four names, and there should only be names starting with the same letter in a row. I know how to set up a GridView, just not how to set it up in this format. The screenshot below shows what I would like to do:

推荐答案

请为网格或TableLayout布局文件table.xml。使该电池的布局文件cell.xml。现在订购名字并把它们放到合适的细胞膨胀的cell.xml。

Make a layout file table.xml for the Grid or TableLayout. Make a layout file cell.xml for the cell. Now order names and put them into appropriate cells by inflating the cell.xml.

LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
...
view = inflater.inflate(R.layout.cell, table, false);
tableRow.addChild(view);
view.setText(name);

我想,你会被自己管理表行的创建。

I think, you'll manage table rows creation by yourself.

这篇关于如何实现在Android中按字母顺序分离GridView的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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