排序按钮按字母顺序 [英] Sort buttons alphabetically

查看:159
本文介绍了排序按钮按字母顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个XML布局一些按钮。他们从字符串资源他们的名字在3种不同的语言。因此,按键并不总是正确的字母顺序排列。所以这是我的问题。我能做些什么,才能使按钮被所有3种语言的字母顺序排序?

i created some buttons in an xml layout. They get their names from string resources in 3 different languages. Therefore the buttons aren't always in the correct alphabetical order. So there's my question. What can i do to make the buttons being sorted alphabetically in all 3 languages?

真诚
约翰·

推荐答案

假设三个按钮是一个的LinearLayout,你也可以继承的LinearLayout和覆盖getChildAt()方法,以你想要的顺序返回查看(你可以制定出一旦字符串被加载)。

Assuming the three buttons are in a LinearLayout, you can subclass LinearLayout and override the getChildAt() method to return the Views in the order you want (which you could work out once the Strings are loaded).

例如

@Override
public View getChildAt(int index)
{
  // translate index into the ordering you want.
  // and put into newIndex...

  return super.getChildAt(newIndex);
}

这篇关于排序按钮按字母顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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