Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何对数据进行排序_Android_Sorting - Fatal编程技术网

Android 如何对数据进行排序

Android 如何对数据进行排序,android,sorting,Android,Sorting,我想对数据进行排序,如果数据是[ex:A,A,2,b,b,1,c,3,d,c,4,e,f,5,g,R,h6,i,T,j,7,H],在示例中有3种类型。大写字母、小写字母、数字。。还有“3”复选框[大写字母,小写字母,数字]。当我选中capsalphabeticCHECKBOX时,所有与caps相关的内容:A、B、C、R、T、H、A、B、C、d。 我选择了哪个复选框,订单必须先到,其余的必须先到。。怎么做?请随便。目前我是ANDROID新手。目前我是这样做的 caps = (Chec

我想对数据进行排序,如果数据是[ex:A,A,2,b,b,1,c,3,d,c,4,e,f,5,g,R,h6,i,T,j,7,H],在示例中有3种类型。大写字母、小写字母、数字。。还有“3”复选框[大写字母,小写字母,数字]。当我选中capsalphabeticCHECKBOX时,所有与caps相关的内容:A、B、C、R、T、H、A、B、C、d。 我选择了哪个复选框,订单必须先到,其余的必须先到。。怎么做?请随便。目前我是ANDROID新手。目前我是这样做的

      caps =  (CheckBox) c.findViewById(R.id.capsCheckBox);
    caps .setOnClickListener(new OnClickListener() {             
          @Override
          public void onClick(View v) {
              sortView.setHint("Sort by Caps");
              if (((CheckBox) v).isChecked()) {
                  numbers.setChecked(false);
                  small.setChecked(false);
                  caps.setChecked(true);
                  numbersSort = false;
                  smallSort = false;
                  capsSort = true;
                  Collections.sort(ListArray, new Comparator<Object>() {
                      @Override
                      public int compare(Object o1, Object o2) {
                          Sample p1 = (Sample ) o1;
                          Sample p2 = (Sample ) o2;
                          return p1.getPriority().compareToIgnoreCase(p2.getPriority());     
                         }
             });
                    dataAdapter = new ListAdapter(ListView.this, ListArray, user);
                    listView.setAdapter(dataAdapter);
                    dataAdapter.notifyDataSetChanged();
                    } else {                            
                        caps.setChecked(true);  
                    }
          }
        });
caps=(复选框)c.findviewbyd(R.id.capsCheckBox);
caps.setOnClickListener(新的OnClickListener(){
@凌驾
公共void onClick(视图v){
setHint(“按大写排序”);
如果(((复选框)v).isChecked()){
数字。setChecked(假);
小。设置检查(假);
caps.setChecked(true);
numbersort=false;
smallSort=false;
卡普梭特=真;
排序(ListArray,新的Comparator(){
@凌驾
公共整数比较(对象o1、对象o2){
样本p1=(样本)o1;
样品p2=(样品)o2;
返回p1.getPriority().compareToIgnoreCase(p2.getPriority());
}
});
dataAdapter=新的ListAdapter(ListView.this、ListArray、user);
setAdapter(dataAdapter);
dataAdapter.notifyDataSetChanged();
}否则{
caps.setChecked(true);
}
}
});

那么,你这样做有什么不对?错误?输出不良?你试过怎么解决它?请具体点。@Eric smallAlphabet我正在以正确的方式获取输出。但是capsAlphabet geting worng输出,因为我将其设置为反向&我将输出设置为json proirity.ex:json geting ex:proirity=“caps”或proirity=“small”或proirity=“number”。怎么做有什么想法吗please@Eric我以这种方式获取json数据:“优先级”:“caps”或“priority”:“small”或“priority”:“number”如何排序。