Tag Archives: The android

[Android] method of removing title bar and using request window feature (Window.FEATURE_ NO_ Title); why does it fail

Use RequestWindowFeature (window.feature_no_title) to hide the cause of the title bar failure.
might be an activity that inherits from AppCompatActivity.
Create an activity that inherits an activity. Create an activity that inherits an activity.
The first method is often used when getting started:

requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove the title bar Note that this sentence must be written in front of the setContentView() method, otherwise it will report an error

The second is defined in the AndroidManifest.xml file

<application android:theme="@android:style/Theme.NoTitleBar">

Wrote, then the application will remove the title bar, if just want to get rid of a certain Activity of the title bar, you can add this property to the Activity inside the tag
the third: this is not commonly used in general application, is in the res/values below to create a new style. The XML file

<?xml version="1.0" encoding="UTF-8" ?>
<resources>
    <style name="notitle">
        <item name="android:windowNoTitle">
            true
        </item>
    </style>
</resources>

In this way, we have a custom style, which is equivalent to a theme, and then define it in the AndroidManifest.xml file, which also removes the title bar

<application 
    android:icon="@drawable/icon" 
    android:label="@string/app_name" 
    android:theme="@style/notitle">

Create an Activity that inherits AppCompatActivity by default

getSupportActionBar().hide();
//Remove the title bar Note that this sentence must be written after the setContentView() method

2 You can do the following configuration in AndroidManifest.xml so that there is no title bar

<application
   android:theme="@style/Theme.AppCompat.NoActionBar">

Solve the problem of multiple root tags in as

In as, multiple root tags usually appear when a piece of code is copied to another space

In the first case, the root tag of the original code is copied when the code is copied. In the second case, the code is not put into a package in another space to check whether the package in another space covers the new code

“Failed to convert @ drawable / XX into a drawable exception details are logged in window”

Problem description

Image resource reference error, there are usually the following similar error logs:

java.lang.NumberFormatException: Color value 
'@drawable/xx' must start with #

reason

The most likely cause of this problem is that your image resource name is wrong, and it is likely to start with a number. In Android, if your image is named after a number, the system will treat it as a hexadecimal color value by default, and the definition of these color values often starts with “#”, so there is the following numberformatexception.

Solution

At this time, you need to check whether the name of the wrong resource starts with a number. If it starts with a number, rename it. If not, try to check whether the name of the resource starts with a space in eclipse (of course, the error at this time is that the drawable file cannot be found). If so, modify it. If not, delete the image and add it again.

After renaming, if the layout file cannot be displayed normally, refresh the preview of the layout view or restart the development tool.

AVD prompt Error:Could not Parse error string solution

Error:Could not parse Error String solution
Solution to the cause of the problem

The problem
Today, when installing APK into AVD, I found the virtual machine prompts installation failed:
The APK failed to install.
Error: Could not parse error string
The reason for this error is also unclear. At first, I thought it was just the installation package, but it didn’t work after three or four installation packages. I checked the API version and SDK version and found no problem, and it was running normally on the real machine.

The reasons causing
To get the best speed out of AVD, AS often recommends using the same CPU architecture AS your PC when installing AVD, which defaults to x86 architecture, while APK USES ARM architecture, which creates incompatibility.
When installing in a terminal, use the following command:
adb install path_to_your_app/name_of_your_app.apk
You may see the following error:
adb: failed to install name_of_your_app.apk: Failure [INSTALL_FAILED_NO_MATCHING_ABIS: failed to extract native libraries
The solution
1. Apk can be installed by installing an ARM-based AVD in AS (but the virtual machine is very, very card).

2. If you are compiling the program, you can change the program to x86 in the option, which can also run in the virtual machine.

errorCode: 500, msg: , result: {“Message”:”There was an error processing the request

Recently, I encountered this bug in my project:
sendRequest(L:249): errorCode: 500, msg: , result: {“Message”:”There was an error processing the request.”,”StackTrace”:””,”ExceptionType”:””}, url: http://www.xxxx.cn/api/m1/xx/xx/xxxx?name=0416
Interaction mode :WebService
Request method, using get and post are not good, have not been able to find the reason, baidu and Google, also did not find the desired answer, the question has been stuck here for a long time, and then accidentally, comment out the request header, the result sent the request again, found the problem got, the request through!
It turned out that it was caused by the request head. Why can’t you add the request head?I don’t know for the moment, so I will make a record first and then analyze it later.