第一个Android测试项目不启动 [英] First Android Test Project does not start

查看:135
本文介绍了第一个Android测试项目不启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建我的第一个Android应用程序,但它根本不启动。

I'm creating my first android application but it does not start at all.

在我的src> android.SampleApp我创建了一个名为Main.java使用Java文件:

In my src > android.SampleApp I created a java file named Main.java with:

public class Main extends Activity {

// Will be connected with the buttons via XML
public void myClickHandler(View view) {
    switch (view.getId()) {
    case R.id.btn1:
        ((EditText) findViewById(R.id.txtContent)).setText("Button 1 Clicked");
        break;
    case R.id.btn2:
        ((EditText) findViewById(R.id.txtContent)).setText("Button 2 Clicked");
        break;

    }
}
}

在我的资源>布局> main.xml中:

In my res > layout > main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView  
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="@string/hello" android:id="@+id/txtContent"/>
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button One" android:id="@+id/btn1"></Button>
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button Two" android:id="@+id/btn2"></Button>

我的Andr​​oidManifest.xml中的内容:

My AndroidManifest.xml content:

<?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="android.SampleApp"
  android:versionCode="1"
  android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">


</application>
<uses-sdk android:minSdkVersion="7" />

我得到这个错误:


  1. [2010-02-02 1时46分26秒 - SampleApp]!Android的启动

  2. [2010-02-02 1时46分26秒 - SampleApp]亚洲开发银行运行正常

  3. [2010-02-02 1时46分26秒 - SampleApp]!没有启动活动找到

  4. [2010-02-02 1时46分26秒 - SampleApp]!这​​次发射将只同步设备上的应用程序包

  5. [2010-02-02 1时46分26秒 - SampleApp]执行同步

3和4行是红色突出显示。

Lines 3 and 4 is highlighted red.

有人能带领我的方向是正确的,只是让应用程序显示在模拟器上?

Could someone lead my in the right direction to just get the application to show on the emulator?

Android 2.1的SDK与Eclipse

Android 2.1 SDK with Eclipse

推荐答案

您缺少在下面的&LT;活性GT; 在清单文件标记:

You are missing the following in your <activity> tag in your manifest file:

        <intent-filter . . . >
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

有关详细信息请参见这里

这篇关于第一个Android测试项目不启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆