lolhuangjinbiao 2017-01-09 16:02 采纳率: 33.3%
浏览 850

小菜鸟级:Android创建和加载布局问题

照第一行代码敲的,发现根本不能运行,故来请教各位大神。
首先布局文件first_layout.xml:
<?xml version="1.0" encoding="utf-8"?>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<Button
    android:id="@+id/button_1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string Button 1" />


其次firstActivity.java中:
package com.example.activitytest;
import android.app.Activity;
import android.os.Bundle;

public class FirstActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.first_layout);
}

}
最后AndroidMainfest中:
package="com.example.activitytest"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="21" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/Button 1"
    android:theme="@style/AppTheme" >
    <activity
         android:name=".FirstActivity"
         android:label="This is FirstActivity" >
         <intent-filter>
             <action android:name="android.intent.action.MAIN" />
             <category android:name="android.intent.category.LAUNCHER"/>
         </intent-filter>
     </activity>   
</application>


代码如上,但却不能运行,错误怎么纠正呢?

  • 写回答

5条回答

  • JE_GE 2017-01-09 16:10
    关注

    具体什么异常啊,不是怎样排
    多半是环境都没有搭建好

    评论

报告相同问题?

悬赏问题

  • ¥15 arduino控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥85 maple软件,solve求反函数,出现rootof怎么办?
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题