Android development framework and android framework
I always think that direct development without frameworks is cumbersome. There are many java projects, I use ssh and php, and I have not found a suitable one under ThinkPHP and Delphi, what about Android? I searched online today and found many good frameworks. I compared them and found two useful frameworks: Afinal and xUtils.
Afinal:
Http://github.com/yangfuhai/afinal
XUtils:
Https://github.com/wyouflf/xUtils
XUtils fork a branch on Afinal.
Both frameworks use the annotation method, which is really convenient to use:
Brief Introduction:
Afinal:
Http://www.oschina.net/p/afinal/
XUtils Source:
Http://my.oschina.net/u/1171837/blog/147544
If you are interested in the framework, try it.
Thank you for providing the tools!
The following is an example of simple controls and event injection:
Xml:
<RelativeLayout xmlns: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" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <TextView android:id="@+id/tvHello" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> <Button android:id="@+id/btnHello" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="68dp" android:layout_toRightOf="@+id/tvHello" android:text="Button" /></RelativeLayout>
Java:
Package com. example. myxutils; import android. app. activity; import android. OS. bundle; import android. view. menu; import android. view. view; import android. widget. textView; import com. lidroid. xutils. viewUtils; import com. lidroid. xutils. view. annotation. viewInject; import com. lidroid. xutils. view. annotation. event. onClick; public class MainActivity extends Activity {// The view annotation of xUtils requires the id to be provided so that code obfuscation is not affected. @ ViewInject (R. id. tvHello) TextView tvHello; @ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_main); // inject ViewUtils into the Activity. inject (this); // inject view and event tvHello. setText ("Hello, Garfield! ") ;}@ OnClick (R. id. btnHello) public void testButtonClick (View v) {// The method signature must be consistent with the requirements in the interface. tvHello. setText (" this is a button event! ") ;}@ 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 ;}}
The code is much simpler!