这就是我尴尬的DB看起来像atm。我想尝试根据年龄对嵌套的哈希进行排序。我已经环顾四周了,所有我能找到的是如何在哈希中对哈希进行排序,但是当嵌套的哈希值在数组内时则不行。我确定有一些简单的方法来改变结构或按照它的方式对其进行排序。
{ :room1 => [{
:fred => { :name => "Fred", :age => 23 },
:joan => { :name => "Joan", :age => 18 },
:pete => { :name => "Pete", :age => 54 }
}],
:room2 => [{
:jan => { :name => "jan", :age => 2 },
:eric => { :name => "eric", :age => 3 },
:stan => { :name => "stan", :age => 1 }
}]}
提前致谢! 顺便说一句,这是我在这里的第一个问题。要温柔^^。
答案 0 :(得分:0)
试试这个
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
Holder holder=new Holder();
View rowView;
rowView = inflater.inflate(R.layout.item_category_list, null);
holder.tv=(TextView) rowView.findViewById(R.id.textView1);
// crasher here.
holder.img=(ImageView) rowView.findViewById(R.id.imageView1);
holder.tv.setText(result[position]);
holder.img.setImageResource(imageId[position]);
rowView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(context, "You Clicked "+result[position], Toast.LENGTH_LONG).show();
}
});
return rowView;
}