Android sorting an ArrayList

Title of my original article: How to sort an ArrayList in Java

Class Test {
public String name;
public String sirName;
}
ArrayList<Test> res = new ArrayList<Test>();
res.add(…);
res.add(…);
Comparator<Test> comperator = new Comparator<Test>() {
@Override
public int compare(Test object1, Test object2) {
return object1.name.compareToIgnoreCase(object2.name);
}
};
Collections.sort(res, comperator);
Share

Delete a directory with DDMS

Unfortunately you can’t.

The only way to delete a directory from a Android device connected with adb is to execute:

adb shell rm -r /path/to/dir

and only if you have permissions, ie you have a rooted device or you are working with Android’s emulator.

Share

Android custom dialog with no title

Dialog dialog = new Dialog(mContext);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialoglayout);
TextView textup = (TextView) dialog.findViewById(R.id.mapDialogTextUp);
textup.setText("test");
dialog.show();
Share