1. Set the startup mode for each activity in the project (if the activity exists in the stack, it is reused and mentions the top of the stack, and no new activity is created)
Android:launchmode= "Singletask"
2. If the layout in the interface is changed by a soft keyboard that pops up, add the following code to the corresponding activity.
Android:windowsoftinputmode= "Adjustpan|statehidden"
3. Remove the effect of ScrollView on the edge:
Scrollview.setoverscrollmode (View.over_scroll_never);
Remove the effects of the ListView and Viewpager pull edges
Android:overscrollmode= "Never"
4. Remove the GridView Item click Effect
Android:listselector= "@android: Color/transparent"
or implemented in code:
Gridview.setselector (New colordrawable (color.transparent));
5. In ScrollView put the full display of the ListView and GridView, after overriding the default three methods, rewrite the Onmeasure () method. Overriding the ListView and GridView
public void onmeasure (int widthmeasurespec, int heightmeasurespec)
{
int expandspec = Measurespec.makemeasurespec (integer.max_value >> 2, measurespec.at_most);
Super.onmeasure (Widthmeasurespec, Expandspec);
}
6. When using afinal to access data to the database, the defined class if there is an id attribute do not set the value of the ID, afinal the default database has an id attribute.
7. When matching data, carefully consider the parameters, do not waste unnecessary time.
8. Onactivityresult () occurs before Onresume ().
9. Get the item item for the GridView or ListView
Because the following is already configured in the adapter
Private List<sortmodel> List;ride
Public Object getItem (int position) {
return List.get (position);
}
Here's how to get each item:
Gridview.setonitemclicklistener (New Onitemclicklistener () {
@Override
public void Onitemclick (adapterview<?> arg0, View arg1, int arg2,
Long Arg3) {
TODO auto-generated Method Stub
Sortmodel model = (Sortmodel) arg0.getitematposition (ARG2);
}
});
10. If at some point in time to determine whether the first download and save to the database of some content needs to be updated, it is important to ensure that the data download is successful and then save the point in time, and will be placed in every boot will be executed somewhere to execute.
12.alt+shift+j Javadoc is generated quickly, but the cursor is placed in the class.
13. If many places in the layout are long, you can draw a style
14. If there is too much nesting, resulting in decreased reading, you can include a layout with include
- <!--the id attribute in the Include tag (ANDROID:ID), the id attribute in the layout layouts referenced does not work, and it is suspected that the layout outer layer of its reference is wrapped in an include tag
- Or a property that overrides its contents id-->
- <!--If there is no include tag, all layout code is written in an XML file, and the interface appears redundant and poorly readable. And when the interface is loaded in order, the previous layout cannot
- Call the layout ID that follows it. With include, you can refer to the layout id attribute in an include after
- <include android:id= "@id/titlelayout" layout= "@layout/app_title"/>
15. If there is too much sex in the activity, you can extract a parent class, usually called baseactivity
16. If you want to fit, create a values folder based on the current phone screen size (high in front, wide in the rear), and configure the size in the Dimens folder.
17. If you want to press the back key of the phone, you can override OnKeyDown in the inheritance activity class and then return to set the return value to true.
18. If one enters activity, the solution to the keyboard pops up:
To prevent entry into the Activity,edittext to get the focus pop-up Input Method dialog box, only need to androidmanifest.xml the corresponding activity tag to add the following sentence can be achieved.
Android:windowsoftinputmode= "Statehidden|adjustresize"
GetWindow (). Setsoftinputmode (WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);//The soft keyboard does not pop up by default
19. With regard to the setting of visibility, invisivible is not visible but occupies a position, gone not only invisible but completely disappears, does not occupy position.
20. The project to import GitHub into eclipse is basically samples and the library.
1) First import the samples and library into the ANDROIDSDK samples list (e.g. ANDROID-17)
2) Right-click Newèothers and select the following
If you put it in the ANDROID-17, tick it in the corresponding place.
Then find the appropriate data import.
21. Set No title bar
Requestwindowfeature (Window.feature_no_title);
22. Icons
HDPI 72*72
LDPI 32*32
MDPI 48*48
XHDPI 96*96
XXHDPI 144*144
23. Write EditText, some mobile phone without the problem of the resolution of the cursor, this sentence written on the line.
Android:textcursordrawable= "@null"
24. Remove the ImageView exclamation mark
android:contentdescription= "@string/image"
Remove the LinearLayout exception
Android:baselinealigned= "false"
25.progressbar can be set to disappear by the return key.
Dialog = Progressdialog.show (context, STR1, str2, False, true);
The last Boolean value is set to true.
When canceling, use Dialog.cancel ();
26. When loading data from the network, display to the page, be sure to wait until the data is loaded successfully and then display the corresponding control.
27. If you define a class that will use the properties of this class in the future, even if you initialize a null pointer without a value, make sure you have a value before using it.
People people = new people ();
It is not empty to write people.
People Peoplea = new people ();
Peoplea.setname ("123");//If the Name property is set, the following does not report an error, otherwise a null pointer exception is reported, because the name is not assigned, Peoplea.getname () default value is null;
if (Peoplea.getname (). Equals ("123")) {
LOG.E ("", "no error, class is empty!") ");
}else{
LOG.E ("", "no error, class is not empty!") "+peoplea.getage ());
}
When using the class:
people people = NULL;
if (people = = null) {//people At this time is null,null cannot be judged by equals with any string, otherwise a null pointer exception is reported.
LOG.E ("", "no error, class is empty!") ");
}
28. The security code of the Baidu map is the shal value of Eclipse, the operation of getting the key value
Get method: Windowèpreferencesèandroidèbuild
Then +;+ the package name in the back, you can apply for success.
29. When using the Afinal framework in fragment, The toast that pops up at the time of failure is not used getactivity () and sometimes a null pointer is reported.
30. In the program as long as there is a need for time-consuming operation, add a dialog that can be canceled.
31. The class is not assigned a value when it is null, such as: Private String str;
Assignment is not NULL, private String str = "";
This is the string with a length of 0.