Android scattered knowledge points

Android scattered knowledge points

why Android's update attempt operation must be carried out in the main thread?

This is because view components in the Android system are not thread-safe. Usually the main thread should be responsible for creating, displaying and updating the UI, starting child threads, and stopping child threads. Let the child thread complete the calculation and send a message to the main thread to update the UI, and let the main thread update the UI. This prompted the Handler mechanism in Android.
How to change the API version that Android Studio compiles against?

Change the compiled version of the Android API through the Flavors tab of the module setting; after the
Xiaomi mobile phone changes the application icon, does the icon on the desktop change?

The problem is solved after restarting;

why is the EditText cursor not showing?

First set the cursorVisible property to true, then set the textCursorDrawable (the background color is not the same as the control background color), the textCursorDrawable property is a property that was introduced in API11;
how to use the android:listSelector property of ListView?

a. Solve why it is invalid; b. Find an alternative method: First, set it in the getView() method of the Adapter implemented by yourself: if (position == selectItem) { convertView.setBackgroundColor(Color.RED); } else { convertView .setBackgroundColor(Color.TRANSPARENT); } Then, in the onItemClick() method, set as follows: adapter.setSelectedItem(position) adapter.notifyDatasetInvalidated();
b.
How to set specific styles for some texts of TextView?

To style some text in TextView, you need to use the SpannableStringBuilder class, which provides the method setSpan(Object what, int start, int end, int flags), where what can be an instance of the following classes: URLSpan; ClickableSpan; BackgroundColorSpan; ForegroundColorSpan; MaskFilterSpan; AbsoluteSizeSpan; RelativeSizeSpan; ImageSpan; ScaleXSpan; StyleSpan; SubscriptSpan; SuperscriptSpan; TextAppearanceSpan; TypefaceSpan; RasterizerSpan; StrikethroughSpan; UnderlineSpan; Examples, such as ForegroundColorSpan's instance forgroundColorSpan; c. Call the setSpan method, specify the starting position for style modification, and fill in the parameters; d. Call the setText(SpannableStringBuilder builder) method of TextView;

mac version eclipse imports Chinese garbled characters in Android projects How to solve the problem?

1. Find Text File Encoding in Preference, select Other, and manually enter GBK. 2. Select the garbled file, right-click to select Properties, and modify it in Text File Encoding (this is the modification method for a single file), for all *.java files can be set in General->Content Type->Text->Java Source Files->Default Encoding in Eclipse's preferences.

To be continued

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326679632&siteId=291194637