1. Android Image Adaptive
Android from 1.6 and higher, Google has added auto-fit functionality to facilitate the porting of various resolution models to developers
<supports-screens
Android:largescreens= "true"
Android:normalscreens= "true"
Android:smallscreens= "true"
Android:anydensity= "true"/>
2./* Get screen pixel and screen density */
Displaymetrics metrics=New displaymetrics ();
Getwindowmanager (). Getdefaultdisplay (). Getmetrics (metrics);
int width=metrics.widthpixels;
int height=metrics.heightpixels;
float density=metrics.density;
int densitydpi=metrics.densitydpi;
3, Android2.2 in Match_parent and fill_parent is a meaning. Two parameter meaning, match_parent more appropriate, so from 2.2 onwards two words can be used. So if you consider the use of the lower version, you need to use fill_parent.
4. Read the phone book
Androidmanifest.xml
<uses-permission android:name="Android.permission.READ_CONTACTS"></uses-permission>
Java File:
Public void onCreate (Bundle savedinstancestate) {
Super. OnCreate (savedinstancestate);
Setcontentview (r.layout.activity_contacts);
TextView TV = new TextView (this);
TextView TV = (TextView) Findviewbyid (R.ID.TEXTVIEWC1);
String string = "Contact is as follows: \ n";
Try {
Get Contentresolver Object
Contentresolver contentresolver = Getcontentresolver ();
Get the cursor for starting an item in the phone book
cursor cursor = Contentresolver.query (
Contactscontract.contacts. Content_uri, null, null, null,
null);
Move Cursor Down
while (Cursor.movetonext ()) {
Get Name of contact person
int namefieldcolumnindex = cursor
. Getcolumnindex (Phonelookup. Display_name);
String contract = cursor.getstring (Namefieldcolumnindex);
Get phone number
intnumberfieldcolumnindex = cursor
. Getcolumnindex (Phonelookup. number); String number =
Cursor.getstring (Numberfieldcolumnindex);
string + = contract + "\ n";
}
Cursor.close ();
Tv.settext (string);
Setcontentview (TV);
} catch (Exception e) {
E.printstacktrace ();
Log. I (TAG, e.tostring ());
}
}
5, Window switch public void onCreate (bundlesavedinstancestate) {
Super. OnCreate (savedinstancestate);
Setcontentview (r.layout. Activity_01);
Log. I (TAG, "onCreate");
Button button1 = (button) Findviewbyid (r.id. Button11);
/* Listen for the button's event information */
Button1.setonclicklistener (new Button.onclicklistener () {
Public void OnClick (View v) {
Create a new Intent object
Intent Intent = new Intent ();
Specifies the class to start intent
Intent.setclass (Activity01. this, Activity02. class);
Start a new activity
StartActivity (Intent);
Close the current Activity
Activity01. this. Finish ();
}
});
}
6, Android.intent.action.MAIN determines the activity that the application starts first, Android.intent.category.LAUNCHER determines whether the application appears in the program list. Main and launcher are also set to make sense
Android Common Knowledge Notes