only re-write the single-argument constructor. If we only add custom views to the Activity in XML Layout mode, we can write only the constructor of double parameters. To prevent errors, we recommend that you repeat the single and double parameters.
3) Select a part of the write-back callback function. You can select a number of write-back functions as needed. Generally, the onDraw (Canvas) method is used.
4) after completing the above steps, we will complete the custom View. We can add it to ou
Android multi-screen adaptation: Part 1: android adaptation
1. In the xml layout file, the width and height of the control are dp, And the font size is sp.
2. dynamically adapt to the screen width and height to obtain the screen width and height:
Method 1:
/*** Screen width
/********************************************************************************************* author:conowen@ Big Bell* e-mail:conowen@hotmail.com* Http://blog.csdn.net/conowen* Note: This article for the original, only as a learning exchange use, reproduced please indicate the author and source.
********************************************************************************************/
1. JNI Introduction
JNI is all called Java Native Interf
. Generally, an application or system will broadcast an Intent temporarily in some events (insufficient battery or short message calls, we can register a Broadcast Receiver to listen to the Intent and obtain the data in the Intent.
How to register and use broadcast receiver in manifest and code
1) Register in AndroidManifest. xml
2) register in the code
1. IntentFilterfilter = newIntentFilter ("
Learn android from scratch (Data Storage (1) SharedPreferences attribute file. 35 .)
There are five ways to save data in android:
Shared Preferences
Store private primitive data in key-value pairs.
Key-value pairs of the corresponding attribute file storage
Internal Storage
Store private data on the device memory.
Device memory storage
, and more interaction is generated between these components. We can regard Fragment as a "small Activity", which is more concise.
Ii. simple use of Fragment
Then we will explain how to simply display two Fragment instances.
1. Add Fragment in XML:
Create Fragment1 and Fragment2. (Note: You may have two packages to import to android. app. fragment or android
startup:
/*** 1. No matter whether a service is bound or created, the service will only be created once (that is, oncreate will only be called once)* 2. If you have already started, bind* 3. If bind already exists, start* 4. If you have already started and bind, you cannot use stopservice. You can only use unbind and then call onstop (this will not be called)* 5. If BIND is already in use and start is enabled, stopservice does not work. You can only
Android-use socket communication to establish Network Chat Room 1, android-socket
First, create a server program:
1. MyServerSocket. java
package com.test.test;public class MyServerSocket {public static void main(String[] args) {new ServerListener().start();}}
2. ServerListener. java is used to listen for port connecti
There are too few excellent Chinese books on Android game development, and there are indeed many English books.
There is no way to learn English. I don't know where to use translation tools!
In order to improve my English proficiency and memory intensity, I sent some useful pieces in the book to the top.
The following is a simple example:
The
Http://schemas.android.com/apk/res/android"
one of the selected or not
(2) android: text = "" ----- indicates the value displayed after the current control
Use the OnCheckedChangeListener listener
8. RadioGroup and RadioButton
Similar to CheckBox
The difference is that Radio is a single listener and also uses the OnCheckedChangeListener listener.
Generally, RadioButton is not used separately. Instead, RadioButton is put into the RadioGroup and used as a group of buttons.
The preceding
Due to the diversity of Android devices and a large number of third-party Android systems, we cannot test all device scenarios. Therefore, it is almost impossible to develop a completely bug-free application, so when the application forces Close on the user's device, can we capture this error, record the user's device information, and then let the user choose whether to feedback the stack information? Throu
Android open-source project SlidingMenu Study Notes (1), androidslidingmenu
SlidingMenu is a popular UI Technology in applications, which can achieve a dazzling sliding effect. SlidingMenu is a Project hosted on Git and is open-source and free of charge, slidingMenu is imported to the required project as a Library. SlidingMenu may be implemented in different ways in the future. You can download it at the fo
Android studio (1)
I wrote a blog for the first time and got into touch with android studio. I didn't even use eclipse before, because I wanted to make some apps for myself, so I entered the deep hole in android development. To learn new things, you still need some enthusiasm and guidance. enthusiasm stems from my pers
. setAction (Intent. ACTION_CALL); // Where ACTION_CALL is the static member variable of the Intent class, which can be called directly by the class // corresponding string "android. intent. action. CALL"
2. Data attributesThe Action attribute describes an "Action" for the Intent object, so the Data attribute provides operation Data for the Action attribute of the Intent object. Note that the Data attribute only accepts one Uri object. A Uri object is
startSystemServer)
{
// You can see this sentence again, indicating that the system has restarted.
LOGD ("\ n >>>>>>>>>>>>>>> AndroidRuntime START
// 1. Start the VM
/* Start the virtual machine */
If (startVm ( mJavaVM, env )! = 0)
Goto bail;
// 2. register the jni Function
/*
* Register android functions.
*/
If (starregulatory (env)
LOGE ("Unable to register all
, ContentProvider, and Application ).
2. Steps for Android Unit Testing
Here I write a simple tested class MathUtil. There is only one tested method in this test class. sum is used to calculate the sum of the two integers.
Package com. jph. simpleapp;/*** tested class * @ author jph * Date: 2014.10.18 */public class MathUtil {public MathUtil () {// TODO Auto-generated constructor stub} public int sum (int
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.