Android Butterknife Frame

Source: Internet
Author: User

Android Butterknife Framework Annotations Raiderstime 2014-02-27 09:28:09 msquirrel original http://www.msquirrel.com/?p=95

First, the principle.

Recently found a very useful open source framework, pretty good, can simplify your code, is about annotations. Not much to say directly into the use of steps to explain.

Second, step.

1, the preparation stage, first to the official website (http://jakewharton.github.io/butterknife/) on the jar package, download down.

2, the download down the jar package, put in the project Libs, will automatically import the project.

3, the configuration eclips, the mouse alignment needs the annotation item, right click Poperties–>java compiler–>

Annotation procession–> hook to Enable project specific settings The others will automatically hook up.

–> Factory Path (Hook enable project specific settings) –> last add .... JARs the jar package that was just downloaded. This eclips configuration is possible.

4, the following is a picture explanation.

5, is to use annotations, directly on the code.

XML section

<RelativelayoutXmlns:android="Http://schemas.android.com/apk/res/android"xmlns:tools="Http://schemas.android.com/tools"android:layout_width= "match_parent" android : Layout_height= "match_parent" > <textview android:id= "@+id/tv_test" android:layout_width=< Span class= "value" > "wrap_content" android:layout_height= "Wrap_ Content "android:layout_centerhorizontal=" true " android:layout_centervertical= "true"  Android:text= "@string/hello_world" tools:context= </relativelayout> java part    
Package com.msquirrel.main;Import Butterknife. Butterknife;Import Butterknife. Injectview;Import Butterknife. OnClick;Import Android.os.Bundle;import android.app.Activity; import Android.widget.TextView; public class mainactivity extends Activity { @InjectView (r.id.tv_test) TextView tvtest; @Override public void OnCreate (Bundle savedinstancestate) { super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); Butterknife.inject (this); Tvtest.settext ("test");} @OnClick (r.id.tv_test) public void Sayhi () {Tvtest.settext ("hello!");}}    

This will allow you to use annotations if you are finished.

Android Butterknife Framework

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.