第一次Android应用程序错误 [英] First time android application errors

查看:175
本文介绍了第一次Android应用程序错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以这是第一次使用的香港专业教育学院Eclipse和Android和我只是想创建一个项目。

So this is the first time ive used eclipse and android and am just trying to create a project.

我经历的步骤去创建一个新的Andr​​oid项目,以创建一个简单的HelloWorld的apk到我的手机上使用。

I went through the steps to create a new android project to create a simple helloworld apk to use on my phone.

我还没有添加任何code自己竟然有许多错误,什么都不会编译。我不知道该怎么办有人可以帮助请。这里是所有code和错误。

I have not added any code myself yet there are many errors and nothing will compile. I dont know what to do can someone help please. here is all the code and errors.

Mainactivity.java

Mainactivity.java

    package com.rikin.myfirstapplication;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;


public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }   


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

activity_main.xml中

Activity_main.xml

<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.rikin.myfirstapplication.MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

</RelativeLayout>

错误:

Error:

也得到这样的:

推荐答案

属性 - > 的Andr​​oid - >添加 appcompat_v7 库。

Go to Properties -> Android -> add appcompat_v7 library.

这篇关于第一次Android应用程序错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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