选择按布尔字段排序的方向是什么?写'ASC'是否正确?按布尔字段排序?
public class Encrypt extends Activity {
private static final int SELECTED_PICTURE=1;
ImageView iv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_encode);
Button open = (Button) findViewById(R.id.button1);
iv=(ImageView)findViewById(R.id.imageView1);
final Button openGallery = (Button) findViewById(R.id.button1);
openGallery.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i=new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, SELECTED_PICTURE);
}
});
}
View.OnClickListener onClick1 = new View.OnClickListener() {
@Override
public void onClick(View v) {
TextView txt = (TextView) findViewById(R.id.textView);
iv.buildDrawingCache();
Bitmap bitmap = iv.getDrawingCache();
int pixel_old = 0;
int pixel_new = 0;
int count = 0;
LinkedList<String> colors_list = new LinkedList<>();
//txt.setText( " h: " + color);
for (int i=iv.getMinimumHeight(); i< iv.getMaxHeight();i++){
for(int j=iv.getMinimumWidth(); j<iv.getMaxWidth();j++){
pixel_new= bitmap.getPixel(i,j);
if(pixel_new != pixel_old){
colors_list.add(String.format("%06X",0xFFFFFF & pixel_new));
count =0;
}
else {
}
pixel_old=pixel_new;
}
}
txt.setText(colors_list.get(1)+" "+colors_list.get(2));
}
};
/*
OnTouchListener imgSourceOnTouchListener
= new OnTouchListener(){
@Override
public boolean onTouch(View view, MotionEvent event) {
TextView txt = (TextView) findViewById(R.id.textView);
iv.buildDrawingCache();
Bitmap bitmap = iv.getDrawingCache();
int x = (int)event.getX();
int y = (int)event.getY();
int pixel = bitmap.getPixel(x,y);
String color = String.format("%06X",0xFFFFFF & pixel);
txt.setText("p: "+pixel+" h: "+color);
return true;
}};
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case SELECTED_PICTURE:
if(resultCode==RESULT_OK){
Uri uri=data.getData();
String[]projection={MediaStore.Images.Media.DATA};
Cursor cursor=getContentResolver().query(uri, projection, null, null, null);
cursor.moveToFirst();
int columnIndex=cursor.getColumnIndex(projection[0]);
String filePath=cursor.getString(columnIndex);
cursor.close();
Bitmap yourSelectedImage=BitmapFactory.decodeFile(filePath);
Drawable d=new BitmapDrawable(yourSelectedImage);
iv.setBackground(d);
// iv.setOnTouchListener(imgSourceOnTouchListener);
iv.setOnClickListener(onClick1);
}
break;
default:
break;
}
}
答案 0 :(得分:2)
写ASC&#39;是否正确?按布尔字段排序?
它没有任何问题。在ASC
方向,FALSE
将首先出现TRUE
s。