歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 用Eclipse在Ubuntu下遇到的一些小問題

用Eclipse在Ubuntu下遇到的一些小問題

日期:2017/2/28 16:16:02   编辑:Linux教程

在Ubuntu下把工程目錄直接拷貝回來放在eclipse到工程目錄裡居然報錯裡

前些天公司那麼大的項目也都沒報錯。。。神奇了

控制台錯誤代碼

Unable to execute dex: wrapper was not properly loaded first
Conversion to Dalvik format failed: Unable to execute dex: wrapper was not properly loaded first

查了一下。

解決方案:

sudo gedit /usr/program/eclipse/eclipse.ini

找到Eclipse目錄下eclipse.ini文件,將最後兩句改為
-Xms128m
-Xmx512m
重啟eclipse
然後project->clean一下就OK了

第二個問題是使用TabHost遇到de問題

Android study week, when two days with TabHost encountered two problems:

Question 1. When you run the Activity Your content must have a TabHost whose id attribute is 'android.R.id.tabhost'

Add a Layout time, xml with element selection TabHost, but the ADT did not add id attribute, running, will be prompted to Your content must have a TabHost whose id attribute is 'android.R.id.tabhost' error, need to add the android: id = "@ android: id / tabhost", so on it.

Question 2. When you run the Activity Your TabHost must have a TabWidget whose id attribute is 'android.R.id.tabcontent'

Solution: Modify FrameLayout Add id attribute, ADT xml file automatically generated Id is the android: id = "@ + id/FrameLayout01", need to modify into the following format android: id = "@ android: id / tabcontent", this estimated to be troubled by a large number of beginners, who would have thought would change this place, see the error is easy to modify into tabcontent, but the prefix is not easy to think of. But also in the ADT visual editing this document, the interface shows NullPointerException, this is ADT's a BUG.

Modified xml as follows:

<? Xml version = "1.0" encoding = "utf-8"?>
<TabHost
android: id = "@ android: id / tabhost"
xmlns: android = "http://schemas.android.com/apk/res/android"
android: layout_width = "fill_parent" android: layout_height = "fill_parent">
<LinearLayout Android:id="@+id/LinearLayout01" android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical">

<TabWidget Android:id="@android:id/tabs" android:layout_height="wrap_content" android:layout_width="fill_parent">
</ TabWidget>
<FrameLayout Android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent">
</ FrameLayout>
</ LinearLayout>
</ TabHost>

Note: If TabHost, then the above three marked red must be the same, this is Google's agreement. And a project can have only one TabHost.

TabHost,TabWidget以及FrameLayoutde

android:id標簽命名一定要按照android的規范 然後就沒問題了

Copyright © Linux教程網 All Rights Reserved