Modify Android New Project Java code template
- Enter the%androidHome%\tools\templates\activities\blankactivity\root\src\appPackage
- Copy SIMPLEACTIVITY.JAVA.FTL Save a copy
Open SIMPLEACTIVITY.JAVA.FTL, delete the following code
1 @Override2 Public BooleanOncreateoptionsmenu (Menu menu) {3 //inflate the menu; This adds items to the action bar if it is present.4 getmenuinflater (). Inflate (R.menu.${menuname}, menu);5 return true;6 }7 8 @Override9 Public Booleanonoptionsitemselected (MenuItem item) {Ten //Handle Action Bar item clicks here. The Action Bar would One //automatically handle clicks on the Home/up button, so long A //As you specify a the parent activity in Androidmanifest.xml. - intID =Item.getitemid (); - if(id = =r.id.action_settings) { the return true; - } - return Super. onoptionsitemselected (item); -}
Delete the useless two import statements
1 Import Android.view.Menu; 2 import Android.view.MenuItem;
- Restart Eclipse, create a new Android project, the code that you have to manually delete each time is missing ~
Modify the default layout file for Android projects
- Enter%android_home%\tools\templates\activities\blankactivity\root\res\layout
- Copy ACTIVITY_SIMPLE.XML.FTL Save a copy
Open ACTIVITY_SIMPLE.XML.FTL, replace with the following code
1 <LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"2 Xmlns:tools= "Http://schemas.android.com/tools"3 Android:layout_width= "Match_parent"4 Android:layout_height= "Match_parent"5 android:orientation= "vertical">6 7 <TextView8 Android:text= "@string/hello_world"9 Android:layout_width= "Wrap_content"Ten Android:layout_height= "Wrap_content" /> One A </LinearLayout>
- Restart Eclipse, create a new Android project, and create a new project without manually modifying the layout every time
Modify the default template for Android projects in eclipse