Some details that do not pay much attention

Source: Internet
Author: User

0. http://ant.apache.org/tomcat in server. the XML file to specify the listening port encoding method can solve the problem of Chinese files can not be downloaded, such as port 8080 with uriencoding = "UTF-8", You need to restart the service.

1. Failed to press the button

Buttonl. setclickable (false); true indicates that

However, when the button cannot be set, then set the button listening, the button automatically becomes able to press, so you should listen first and then set.

2. Make the button invisible

Button. setvisibility (view. Invisible); the view. Invisible parameter is visible.

After the button is set to invisible, the button still occupies the place, so that the button does not occupy the place, and the parameter is set to view. Gone.

3. When the checkbox is setchecked () in listview, whether it is true or false, the checkbox you clicked will be setchecked () again when it slides out of the screen.

For example, if you initially set false for a checkbox in the getview code, click set true on the screen to make the checkbox slide out of the screen and draw it back, you will find that the checkbox is changed to false.
After the following judgment is added to the listview test, it is found that after clicking a checkbox, the checkbox of the 10 items that are clicked is also changed to checked.
If (convertview = NULL)
{
Convertview = inflate. Inflate (R. layout. violation_staff_item, null );
Holder. Box = (checkbox) convertview. findviewbyid (R. Id. violation_staff_item_checkbox );
Holder. Text = (textview) convertview. findviewbyid (R. Id. violation_staff_item_child );
Convertview. settag (holder );
}
Else
{
Holder = (viewholder) convertview. gettag ();
}
My solution: 1. Use sharedprefences to store the selected items, delete the previous storage items when you deselect the selected items, and determine the sharedprefences data during getview to perform checkbox operations, this method has been implemented in expandablelistview.
2. Store selected items in the database. When getview is used, the content in the database is determined. Similar to sharedprefences, I have implemented it in expandablelistview, which is more powerful than sharedprefences.
3. Use container storage. I use the list container to store the position of the selected item. When getview is used, the container determines whether there is data in this position. If yes, chechked. I implemented it in listview.

4. when you perform database operations, You need to pack the strings with "'", because the strings can contain spaces and symbols, and there cannot be spaces between "'" And strings, because there are two types of strings: Empty and no space.

5. When data is transmitted using intent, class objects cannot be directly transmitted, and the java. Io. serializable interface of the objects to be passed can be correctly transmitted. Intent. getserializableextra ("key ").

6. key-value pairs stored in the hashmap object are generally obtained through keys. If you do not know the key or want to obtain the key, you can do this: Call the hashmap method entryset to obtain the set <map. entry <K, V> the object iterates the set object to obtain the map. entry <K, V> object.getKey()Method to obtain the key of the hanshmap. (Map. Entry <string,
String> entry: map. entryset ())

7. put the built-in resources of the application in the assets folder and create a directory in it. Note that the resources and directories cannot contain Chinese characters. The method for obtaining resources is as follows: Use getresources (). getassets () method or getassets () method to get the assetmanager object. Next, you can easily get the desired object, for example, get the name of all files assetmanager. list ("") to get all the file names in the assets folder. If there is a folder named XML in the assets folder and there is a file in it, the file name can be obtained as assetmanager. list ("XML"), the path is relative to the assets path, it is easy to get the stream, see the development documentation, the parameter is the name of the relative assets path. If the folder in the assets folder is empty, empty folders are ignored when obtaining the file name in the assets folder. The assets folder contains three folders with files: images, sounds, and WebKit. Images contains two images in PNG format.

8. before the byte type shift, it is best to & 0xff it first. If not & 0xff does not affect English, and sometimes garbled characters may appear accidentally, view the JDK source code and find that & 0xff is before the byte shift.

Public static string bytetostring (byte [] B, int off, int Len) // convert bytes in the small-end mode into strings in the large-end mode {Int J = 0; int Leng = (LEN-Off)/2; stringbuffer sb = new stringbuffer (); For (INT I = 0; I <Leng; I ++) {J = I * 2; sb. append (char) (B [J + 1] <8) | B [J] & 0xff )); // if it is not a part of Chinese characters, garbled characters will appear.} return sb. tostring ();}

9. When constructing classes inherited from broadcastreceiver, you can only use the default constructor. Otherwise, an exception is reported. It makes no sense to pass the value.

10. linux File Permissions: 10 characters, 1 indicates the file type, 2-4 indicates the file owner permission, 5-7 indicates the user permission in the user group, and 8-10 indicates other user permissions, programs in Android are equivalent to other programs. To delete files in other programs, you need the write and executable permissions of the file's parent folder. To write and read files in other programs, you need the executable permissions of the parent folder and the corresponding read and write permissions of the files. Rwx: read/write executable.

11. nested listview in scrollview, the sliding effect of listview will be overwritten by scrollview, And the onintercepttouchevent method of scrollview will be rewritten:

@Overridepublic boolean onInterceptTouchEvent(MotionEvent ev) {return false;}

12. in the getview method of the adapter, specify the view of the sub-item through getlayoutinflater (). inflate (Android. r. layout. simple_list_item_single_choice, parent, false) and getlayoutinflater (). inflate (Android. r. layout. simple_list_item_single_choice, null); the effect is different (the parameter is an example). The three parameters can be used to get the settings of parameters such as the margins of the viewgrop container. The size of the two parameters is completely determined by themselves.

13. The Vibrator class is used to control and query machine vibrations and requires permission for Android. Permission. vibrate.

Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);vibrator.vibrate(200);

14. Add a click listener to the listview, and then execute the upload mitemclick method. It is found that the listview item is choose, but the click event is not triggered. If it is inherited from listactivity, getlistview gets the listview. executing this method triggers the click event.

15. Run the Java command after compiling the file with javac

Exception in thread "main" java.lang.NoClassDefFoundError: com/liu/Test

There are two possible errors: The file is in the current directory rather than in the COM/Liu directory under the current directory, create the COM/Liu directory, copy the file, and run it again, in this case, only the package name is available. Second, the classpath configuration is incorrect. If there is no. In classpath, this configuration will report this problem.

16. In the ontouchevent method of the view, if true is returned, its parent view will not accept touch screen events. If false is returned, the Child view can only receive down events, and other events are consumed. Trigger events are transmitted at the first level from the Child view.

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.