Kjframeforandroid How to use 1

Source: Internet
Author: User

To those who use, want to use, have not used kjframe friends. Kjframeforandroid is divided into four functions: Activity Inheritance Chain specification, HTTP data request and upload download, bitmap loading and listview scrolling only load memory picture, database object storage and collection object storage. There is also a standalone feature Cjframe plugin development framework that supports launching APK apps that are not installed on your phone.
This article original, reprint please specify address: http://blog.kymjs.com/Activity succession chain

Use your activity (Fragment) to inherit from Kjactivity (kjfragment). In the usual development, we often write data initialization, Findview, control property settings and so on in a OnCreate (), which will cause the OnCreate method is too bloated, and using the Kjframe module of the base class activity (Fragment) This problem can be easily solved.

    • The order in which individual methods are called in the base class:
Setrootview (); Used to call SetContent (); The annotation binding initdatafromthread () is executed after the execution of the//setrootview, and (execution is performed asynchronously, for time-consuming operation) threaddatainited (); (Initdatafromthread () will be callback after execution is completed) InitData (); Used to initialize data initwidget (); Used to set the content of the control registerbroadcast (); For registering broadcasts with context menus
    • The annotation-bound control and the set listener use Uilibrary, you can complete the control's Findview and set the Click event with just one line of code, just like the following example, you just need to add @bindview annotations.
@BindView (id = r.id.xxx, click = True); Private Button btn;

This is equivalent to having called the

Private Button btn;  BTN = Findviewbyid (r.id.xxx); Btn.setonclicklistener (this);

Of course, whether to set the Click event is up to you to decide, if not set, then you can not write click=true this sentence.

    • Viewinject Feature and Toast optimization It is troublesome to write a long string of code every time you write a toast. So Kjframe is very human to the toast to do the encapsulation, you just need to call
Viewinject.toast ("hint text");

The Viewinject also encapsulates a popular pop-up dialog box

Popup a pop-up window, with overloaded methods,//You can customize the listener that clicks the OK button and the content text of the pop-up window Getexitdialog (context context); Getdatedialog (String title, TextView TextView)
    • Free usage If you are constrained by the project and cannot inherit the base class of Kjframe, you can still use annotation binding and toast optimization, but the usage is slightly different. If you do not inherit the base class, you need to manually invoke the SetContent () method of the activity when using annotation @bindview
Annotateutil.initbindview (this);

You need to manually pass in a context object when toast is used because there is no inherited framework base class

Viewinject.toast (This, "hint text");

Kjframeforandroid How to use 1

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.