Afinal是一个android的ioc,orm框架,源码下载地址:
第一个例子,用到了Afinal的FinalActivity
package com.example.app1;import net.tsz.afinal.FinalActivity;import net.tsz.afinal.annotation.view.ViewInject;import android.os.Bundle;import android.view.Menu;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.TextView;public class MainActivity extends FinalActivity { @ViewInject(id = R.id.button1) private Button button1; @ViewInject(id = R.id.textView1) private TextView textView1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button1.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { textView1.setText("text set form button"); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; }}
类需要继承FinalActivity
UI绑定,通过注解的方式,是这么用的:
@ViewInject(id = R.id.button1)private Button button1;