Android provides the invalidate method to refresh the interface, but invalidate cannot be called directly in the thread, because it violates the single-thread model: Android UI operations are not thread-safe, these operations must be called in the
Sometimes, our pages may contain some la S. These la s are hidden by default. After a user triggers some operations, the hidden la s are displayed. For example, an activity is used to display the list of friends. After you click "import" in the menu,
Directly rewrite the following three methods in the subclass of the Activity class:
Copy codeThe Code is as follows:
// Rewrite the onCreateOptionsMenu () method. The menu bar is displayed.@ Override
Public boolean onCreateOptionsMenu (Menu menu )
In android development, when the trigger condition is not met, press the return key. Especially when the current Activity needs to send messages to a previous Activity. That is, when Activity1 jumps to Activity3, if startActivityForResult is used,
This is a very simple problem, but every time it is used, it will always be a bit messy. Here we record the steps of Logcat:
1. Declare the tag variable in the Activity (the name is actually casual, as follows:
Private static final String tag = "
After research, I recommend this method:
Copy codeThe Code is as follows: /* Custom thread */
Class MyThread implements Runnable {
Public void run (){
// TODO Auto-generated method stub
// Define your own Variables
While (! Thread.
In the development of android applications, you sometimes need to restrict horizontal and vertical screen switching. You only need to add the android: screenOrientation attribute restriction to the AndroidManifest. xml file.
Ndroid:
Method 1: Activity. runOnUiThread (Runnable)(Experience: This is the best practice. Wherever you want to refresh the page,
Activity. runOnUiThread (new Runnable ()
{Public void run () {update UI }}
);
Method 2: The subthread calls Handler's
When there is a large amount of data in the database, you should note that Using Cursor for query may cause performance problems. The database query Cursor is managed by a CursorWindow, including memory space application and data filling.
Handler is a class used to operate message queues within a thread. This is a bit difficult. Let's talk about it slowly. As mentioned in the previous article, logoff is used to create a message queue for a thread. That is to say, logoff can make
Understanding AsyncTaskAsyncTask is a class added by the Android 1.5 Cubake for asynchronous operations. Previously, Thread in the Java SE library can only be used to implement multi-Thread Asynchronization. AsyncTask is the asynchronous tool of the
AnDroidDraw is an Android application integrated with DroidDraw, which allows you
You can also preview your GUIs on an Android device.
1. First download and install DroidDraw, the version I use is droiddraw-r1b222. Download androiddraw.apk and
Dialog is a control that is required by any system. It is used as an auxiliary window to display some messages or to request the user to take an action.
It is no exception in Android. For more information, see the document.
Precautions for use1.
TextView is a control used to display text labels.
Copy codeThe Code is as follows:/* TextView settings * // * Get the TextView object */
Textview = (TextView) this. findViewById (R. id. textview );
String string = "TextView example! ";
/* Set the
Most of the time, we need to display images on the client and dynamically display the images, that is, constantly switching the images. Next we will look at the specific implementation method. First, we need...Most of the time, we need to display
SQLite Analysis
SQLite is a lightweight, embedded, and relational database. It has been applied in iPhone, Android, and other mobile phone systems. SQLite is highly portable, easy to use, small, efficient, and reliable. SQLite is embedded into the
Recently, the project needs to support emoticon. The addition and resolution of emoticon are basically based on the SmileyParser of Android,Directly paste the Code:
Copy codeThe Code is as follows: public class SmileyParser {
Private static
This is a framework, but it is not that complicated. It is just a base class that is easy to expand. But at least it is framework code.
Copy codeThe Code is as follows: package arui;
Import android. app. Activity;Import android. OS. Handler;Import
Otherwise, Android is especially open. In Android development, this requirement can be achieved by sending a broadcast.
Here is a piece of encapsulated code.
Copy codeThe Code is as follows: public class ShortcutUtil {
Public static void
Very simple, so you can directly look at the code
Copy codeThe Code is as follows: package xxx;
Import android. content. BroadcastReceiver;Import android. content. Context;Import android. content. Intent;Import android.net.
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