Crazy Sinology Android, Hulai Hu read Hu record

Source: Internet
Author: User

Handler A thread can only start Looper to create Handler objects in it for message processing, otherwise the program will have an exception.
The start Looper is implemented by calling the static method Looper.prepare ();
A thread can have only one looper and one MessageQueue, but there may be multiple handler objects. Different handler objects can be used to process different messages in a program.

A timer timer is also a common way to implement multithreaded procedures, but it is not possible to perform UI operations directly in the timer, either through the handler class, the Activity.runonuithread (Runnable) method, or View.post ( Runnable) methods, and so on, to indirectly perform UI operations.

The Asynctask class provides a lightweight, multithreaded-based, background asynchronous work-processing class. Background work is easier, and you can use the Asynctask class only when you want to pass some simple data to the UI thread.

Private static final long serialversionuid = 1L;
If your class serialized on the hard disk, but then you change the field of the class (increase or decrease or rename), when you deserialize, it will appear exception, which will cause incompatibilities.
But when Serialversionuid is the same, it deserialize the different field with the default value of type, which avoids incompatibility issues.

WebView v = (WebView) findViewById(R.id.view);        v.setWebViewClient(new WebViewClient(){            publicbooleanshouldOverrideUrlLoading(WebView view,String url){                view.loadUrl(url);                returnsuper.shouldOverrideUrlLoading(view, url);            }        });        v.loadUrl("http://blog.csdn.net/jijiaxin1989/article/details/44178489");

The Setwebviewclient () method is used to specify the carrier of the Loadurl () method to open the page. The program can run without this line code, but the default initial page index.html page is forwarded by the WebView component to the Android default browser. After adding the second line of code, the page will be opened by the WebView component itself.

1, change the title content: public void Settitle (charsequence title)
2, Hidden title: Requestwindowfeature (Window.feature_no_title);
3. Hide title and top battery level and signal bar (full screen):

public void setFullscreen() { requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 

4 Custom title:

protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState); //预先设置允许改变的窗口状态,需在 setContentView 之前调用,否则设置标题时抛运行时错误。requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.custom_title); //标题区域可设置为 layout ,如此可以有丰富的展现方式 getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_1); }

The res\layout\custom_title_1.xml contains a textview for displaying the caption. Android can put the title as a layout to show, with good extensibility.

<relativelayout  xmlns: Android  = "http://schemas.android.com/apk/res/android"  android:id  = "@+id/screen"  android:layout_width  =" fill_parent " android:layout_height  = "fill_parent"  android:orientation  = "vertical" ;     <TextView android:id= "@+id/left_text"android:layout_width="Wrap_ Content "android:layout_height=" Wrap_content "android:layout_alignparentleft= "true" Android:text="@string/custom_title_left" />                                </relativelayout>

Monitor button, return key intercept, return to previous WebView page

  @Override  public  boolean  onkeydown  ( int  keycode, KeyEvent event) {if  (keycode = = Ke            Yevent.keycode_back) {mwebview.goback (); return         true ;    } return  super . OnKeyDown (KeyCode, event); }

Data parsing
JSON data is a string that is stored as a key-value pair, and the XML data is similar to HTML, and is text that is provided as a label.
JSON is the most commonly used lightweight network data transfer format, and the Android API directly supports the processing of JSON data. The commonly used classes in JSON parsing are jsonobject, Jsonarray, Jsonstringer, Jsontokener, and so on.
For more complex-format data, you still need to use XML format
The Android API provides the following methods for working with XML data:
Dom approach: Tree-based parsing and processing
Sax Mode: Stream-based parsing and processing (push mode)
XML Pull mode: stream-based parsing and processing (pulling mode)
The organization of XML data is a tree-like structure,
The DOM way of processing data is to read all the XML data, construct it into a tree, and then handle the data by some means.
Instead of reading all of the XML nodes into memory, sax processes the data as it is read. Event-based triggering, and so on with the data push out.
XML pull takes the form of active pulling.

WebService, as a mature technology, provides a cross-platform approach to information interaction and is currently the mainstream interactive technology for heterogeneous networks, using KSOAP2 third-party packages.

Crazy Sinology Android, Hulai Hu read Hu record

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.