2014-01-11 109 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项目的根目录] –