2014-01-11 156 views
0

我不得不說,我是Android開發領域的新手。我只是在昨天下載它,並希望看看我今晚能否獲得一些簡單的應用程序。應用程序的Android測試代碼?

以前的代碼是當我把按鈕放在屏幕上時的代碼。我對XML和Java有很好的理解,所以我對這個概念並不陌生,但是我不得不說,我試圖讓Android應用程序工作一段時間,它遇到問題後會遇到問題,從來沒有看到過示例運行。這不可能是一個複雜的問題。

我知道在Eclipse IDE中有一些測試設備是我模擬Nexus 7的。我有一個Nexus 7並希望看到即使在我自己的設備上也能測試它,但首先我必須獲取它甚至在一些仿真中運行。這是我無法想象的。

我的問題是我要去哪裏?

確切地說,您如何獲得一個Android應用程序來編譯和運行,以便您可以在仿真器或Nexus 7的屏幕上看到它的內容。實際上,我沒有看到任何Java代碼,而是看到了XML基本代碼。那是Android系統如何在基於XML的代碼上運行?

的Android代碼:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#0099cc" 
    tools:context=".FullscreenActivity" > 

    <!-- 
     The primary full-screen view. This can be replaced with whatever view 
     is needed to present your content, e.g. VideoView, SurfaceView, 
     TextureView, etc. 
    --> 

    <TextView 
     android:id="@+id/fullscreen_content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:gravity="center" 
     android:keepScreenOn="true" 
     android:text="@string/dummy_content" 
     android:textColor="#33b5e5" 
     android:textSize="50sp" 
     android:textStyle="bold" /> 

    <!-- 
     This FrameLayout insets its children based on system windows using 
     android:fitsSystemWindows. 
    --> 

    <android.support.v7.widget.GridLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" > 
    </android.support.v7.widget.GridLayout> 

    <ImageButton 
     android:id="@+id/imageButton1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@android:drawable/btn_star" /> 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="301dp" 
     android:layout_height="142dp" 
     android:text="Button" /> 

</FrameLayout> 
+2

那究竟是什麼問題? – PsyGik

+1

究竟是什麼^ - 那傢伙說。另外,顯示你使用的Java代碼。 – csmckelvey

回答

0

Android不只是取決於XML代碼,上面的XML代碼是從文件someActivity.xml XML是用來定義活動的接口。如果您使用的是eclipse,那麼請參閱此URL中的圖像http://www.techotopia.com/index.php/Image:Eclipse_android_4.2_main_screen.png

/src /文件夾包含所有Java文件,Android應用程序中的每個Activity都使用XML文件和Java文件進行定義。您也可以創建Java文件,就像支持Java活動文件的附加功能一樣。

/gen /文件夾包含所有自動生成的文件。請參閱developer.android.com瞭解更多詳情。

/bin /文件夾包含生成或編譯的二進制文件。必須在您的Android設備中部署的.apk文件將在您每次構建項目時生成或創建。

/libs /文件夾包含您希望添加以支持您的應用程序的外部庫。

/res /文件夾包含運行應用程序所需的所有資源。術語資源並不意味着RAM,存儲磁盤,它意味着您在應用程序中使用的圖像文件,例如:徽標,背景圖像等,圖像應放置在/ res/drawable-xxx /文件夾xxx中,它表示您應該將圖像置於不同的DPI或分辨率格式,請參考使用photoshop進行圖像編輯以瞭解將圖像調整爲指定大小的更多詳細信息。
/values /文件夾包含定義字符串,顏色等的XML文件,這些文件將在您的應用程序中使用。 /res/Layout /文件夾包含每個活動的所有佈局。這些都是以XML格式定義的,以強大的方式描述活動的界面。

最後,AndroidManifest.xml文件包含有關您希望在應用程序啓動時啓動的活動的所有詳細信息,需要根據Android的安全性授予應用程序的權限設備及其用戶詳細信息。

您將在java文件中編寫業務邏輯,在XML文件中編寫表示邏輯。

請參閱此URL以在Android中創建hello world應用程序。

http://www.techotopia.com/index.php/Creating_an_Example_Android_Application

+0

如果是再次存儲XML文件。我把它放在屏幕上,然後關閉它,認爲我會找到它,然後不能。我經歷了所有的導演幾次,我沒有看到它。 –

+0

這是我沒有找到的文件AndroidManifest.xml –

+0

xxxLayout.xml文件存儲在/ res/layout /文件夾中,而AndroidManifest.xml存儲在/目錄下,[/ - >/root項目的根目錄] –