To show you what Android query can do for user interface development, we've cited an example from their project page.
This is the code before using Aquery:
This is the code after using Aquery:
The familiar jquery grammar emerges again, and the excitement has wood.
Aquery Project Address: https://github.com/androidquery/androidquery
Android query simplifies the process of attaching an event handler. It doesn't build interfaces or anonymous classes, we just have to make sure they don't spell the method names of the event handlers incorrectly.
Copy Code code as follows:
Aq.id (R.id.button). Clicked (This, "buttonclicked");
Trivial problems caused by screen size and API versions can cause a lot of trouble for the device. Android query solves some of the problems by providing its own encapsulation around the API. For example, the function "Aq.hardwareaccelerated11" (); Detects if the device supports API 11 and starts hardware acceleration when appropriate.
When working with different size screens, developers often first create a tablet and then delete and recognize the control until it can match the phone. Generally this means that before attempting to manipulate the control from the background code, you need to check the virtual tree to see if they are actually created from the Axml file.
Android query will link the method according to the criteria (conditionally chaining methods) so that you can avoid all the checks. Consider this piece of code:
Copy Code code as follows:
Aq.id (r.id.address). Text (name). Background (r.color.red). TextColor (R.color.black). Enabled (True). Visible (). Clicked (This, "addressclicked");
If the control address does not exist, all subsequent setup methods and event handlers will stop. Although this may make debugging more difficult, it can significantly reduce the number of lines of code in the OnCreate method.
Aquery also makes it easy to invoke asynchronous HTTP requests. It includes support for simple and multiple partial post operations, and can accept binary, JSON, HTML, and XML-formatted data. In addition, it includes separate support for the picture, and we can use one line of code to download the picture, cache it, and load it into the control.