zoukankan      html  css  js  c++  java
  • 空的安卓工程添加activity

    1.编写类继承activity,并重写onCreate方法

    package org.tonny;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    public class FirstActivity extends Activity
    {
    
    	@Override
    	protected void onCreate(Bundle savedInstanceState)
    	{
    		// TODO Auto-generated method stub
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.layout_first);
    	}
    
    }
    

    2.编写布局文件

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
        
        <TextView 
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Hello"/>
    
    </LinearLayout>

    3.修改清单文件

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="org.tonny"
        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/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name=".FirstActivity"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application>
    
    </manifest>

    4.开启即可运行

  • 相关阅读:
    webpack 配置缓存
    Python-----多线程threading用法
    LINUX 编程定位工具gstack,pstack
    数据库session立即生效(64---8192) SCOPE参数
    shell中wait命令详解
    Go语言学习笔记
    使用go语言数据库
    Oracle数据库管理----性能优化
    数据库索引实例
    Linux串口设置及编程(转)
  • 原文地址:https://www.cnblogs.com/supertonny/p/4532214.html
Copyright © 2011-2022 走看看