Modify the default template for Android projects in eclipse

Source: Internet
Author: User

Modify Android New Project Java code template
  1. Enter the%androidHome%\tools\templates\activities\blankactivity\root\src\appPackage
  2. Copy SIMPLEACTIVITY.JAVA.FTL Save a copy
  3. 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); -}
  4. Delete the useless two import statements

    1 Import Android.view.Menu; 2 import Android.view.MenuItem;
  5. 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
  1. Enter%android_home%\tools\templates\activities\blankactivity\root\res\layout
  2. Copy ACTIVITY_SIMPLE.XML.FTL Save a copy
  3. 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>
  4. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.