Android development framework and android framework

Source: Internet
Author: User

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:

  • You can bind the UI and events in full annotation mode.

  • No need for findViewById and setClickListener

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!

Related Article

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.