Android: Reading Hu record: android:

Source: Internet
Author: User

Android: Reading Hu record: android:

A Handler thread can create a Handler object and process messages only when logoff is started. Otherwise, an exception occurs in the program.
Start logoff by calling the static logoff. prepare (); method.
A thread can only have one logoff and one MessageQueue, but it can have multiple Handler objects. Different Handler objects can be used in programs to process different messages.

Timer is also a commonly used method to implement multi-threaded programs. However, you cannot directly perform UI operations in the Timer. You need to use the Handler class and Activity. runOnUiThread (Runnable) method, or View. post (Runnable) method to indirectly perform UI operations.

The AsyncTask class provides a lightweight multi-thread-based background asynchronous processing class. The background work is relatively simple. You can use the AsyncTask class when passing some simple data to the UI thread.

Private static final long serialVersionUID = 1L;
If your class Serialized is stored on the hard disk, but then you change the field of the class (increase, decrease, or rename), when you Deserialize, Exception will occur, this will cause incompatibility issues.
However, when the serialVersionUID is the same, it will Deserialize different fields with the default value of type to avoid incompatibility issues.

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

The setWebViewClient () method is used to specify the carrier for the loadUrl () method to open the page. If the code program runs without this line, the webpage index.html page is transferred by the WebView component to the default browser of the android system. After the code is added, the page is opened by the webview component.

1. Change the title content: public void setTitle (CharSequence title)
2. Hide the title: requestWindowFeature (Window. FEATURE_NO_TITLE );
3. Hide the title and top battery power 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); // you can set the window status that can be changed in advance. It must be called before setContentView; otherwise, a runtime error is thrown when you set the title. RequestWindowFeature (Window. FEATURE_CUSTOM_TITLE); setContentView (R. layout. custom_title); // The title area can be set to layout, so that there can be a variety of Display Methods getWindow (). setFeatureInt (Window. FEATURE_CUSTOM_TITLE, R. layout. custom_title_1 );}

Res \ layout \ custom_title_1.xml contains a TextView used to display the title. Android can display the title as a layout with good scalability.

<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>

Listen button, Return key interception, return to the previous webview page

    @Override    public boolean onKeyDown(int keyCode, KeyEvent event) {        if(keyCode == KeyEvent.KEYCODE_BACK){            mWebView.goBack();            return true;        }        return super.onKeyDown(keyCode, event);    }

Data Parsing
Json data is a string stored in the form of key-value pairs. xml data is similar to HTML and is text provided in the form of tags.
Json is a commonly used lightweight network data transmission format. android APIs directly support JSON data processing. Common classes for json parsing include JSONObject, JSONArray, JSONStringer, and JSONTokener.
For complex data, xml format is still required.
The android api provides the following methods to process xml data:
DOM method: tree-based parsing and Processing
SAX method: Stream-based parsing and processing (push mode)
Xml pull mode: Stream-based parsing and processing (PULL mode)
The structure of xml data is a tree structure,
To process data in DOM mode, read all xml data first, construct it into a tree, and then process the data in some ways.
SAX does not read all xml nodes into the memory before processing data. Instead, it reads and processes the required data. Event-based trigger, and so on, push data out.
Xml pull adopts active pulling.

As a mature technology, webservice provides cross-platform information interaction methods. Currently, it is a mainstream Interaction Technology in Heterogeneous Networks and uses Ksoap2 third-party packages.

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.