In the previous example, we saw a change in the screen direction. In fact, when the screen direction changes, the onConfigurationChanged () event will occur. Although you can change the direction to display the direction to change, however, the
During development, full screen display, custom titles (using buttons and other controls), and other requirements are often required. Today we will talk about how to control the form display of Android applications.
First, we will introduce an
One of the most popular ways to use it is Java codePublic class Utility {Public static void setListViewHeightBasedOnChildren (ListView listView ){ListAdapter listAdapter = listView. getAdapter ();If (listAdapter = null ){// Pre-conditionReturn;} Int
During Android development, sometimes the system cannot be sleep when the program is running. Otherwise, some operations will stop. Therefore, we need to set disable sleep in two ways: one is to add permissions, and the other is to set in the code.
Google weather api is used in the process of writing the android weather forecast program, while the data obtained by parsing the xml file with sax is in English. The problem of data conversion and display occurs here.For example: Query weather http:
1. First, add android: sharedUserId = "shared id" to In AndroidManifest. xml ---- apk with the same id can be accessed without restrictions.2. Create a Context based on the package name. The createPackageContext method provided in the Activity can
First, create a class HelloWorldActivity:Public class HelloWordActivity extends Activity {
/** Called when the activity is first created .*/
@ Override
Public void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState
Lead: during the development of Android applications, we need to ensure the stability and interface responsiveness of the applications at all times, applications that are unstable or slow in response will provide users with a very poor interactive
TextView in Android is actually equivalent to a Label in many languages (such as Java Swing JLabel), mainly used to display a string. For example:
"@ + Id/lable1"
Android: text ="This is a Label"
Android: layout_width ="Fill_parent"
Android:
Click the program twice in a row to exit the program. This is an interesting program function. Let's introduce my implementation method (You are welcome to give some suggestions ):1. Set a long global variable firstTime = 0 in the Activity to record
1. Under what circumstances:SDK version 20After creating a project, add a custom Activity and define it in manifest. xml.[Html]Android: icon = "@ drawable/ic_launcher"Android: label = "@ string/app_name"Android: theme = "@ style/AppTheme">Android:
Thread creation method:1. inherit the Thread class and override the run () method[Java]Public class testThread extends Thread {@ OverridePublic void run (){// TODO Auto-generated method stubSuper. run ();}} Www.2cto.com
2. Implement the Runnable
In android development, you often need to manually set the location of a ListItem. The location setting functions include:
ListView. setSelection (int position)
ListView. setSelectionFromTop (int position, int y );
Where
Position indicates the index
[Cpp]// Set the font size for a TextView with the id of nameTextView mName = (TextView) findViewById (R. id. name );MName. setTextSize (22 );
When I started to learn about Android, I set the font size with the above Code. It is very comfortable to
After learning about fragement's life cycle and other simple knowledge, I went to the official documentation to learn more about fragement. To add fragement to our UI, I provided two common methods, the first is to use the label declaration in the
1. setParameters failed solution 2. users who do not need to preview Photos may need to download the compiled ROM and add their own applications to the ROM for Silent Installation, it's shameless to make a profit. Now we want to achieve the function
Permissions required for Android to change the wifi status. Although this is a very simple problem, we know that permissions must be added when changing the wifi status. the above two permissions change the wifi status. However, when developing a
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