android开发第一次心的

1.极客精神与态度

遇到bug耐心解决,学习热情,学会环境的使用github,mac,linux。

2. 开始征程

搭建环境:jdk+android idk+eclipes或者android studio+Genymotion+ADT
创建新的工程:需要有Activity(一个活动页面,房子),layout(页面的布局)和res(页面内的资源)等。
填写company Domain和Package name和 Phone
and Tablet
android本身集成了一些Activity的资源
系统默认生成活动页面MainActivity和页面布局acuity_main。
在左边展示中出现gradle(打包工具),app(工程文件),src(资源文件)部分。
用布局文件中的design界面拖动一个按钮进去
<Button
android:id="@+id/three_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/three"/>

其中可以设置按钮的名字,方便再R文件下自动生成引索文件,可以在MainActivity中设置逻辑代码。

findViewById(R.id.three_button).setOnClickListener(new View.OnClickListener(){
            public void onClick(View v){
                //当被点击时触发,显示提醒一定时间,
    Toast.makeText((Context context ,charSquence Text),Toast LENGTH_LONG)).show();

            }
        });

对于其他空间如TextView这个特点是现实背景,诗,字的现实出现在内容框中,代码如下:

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!" />

还有很多很多android属性,如设置id,设置颜色,字体等,安卓有强大的代码提示功能,页可以看官方的API文档,学习。
说到activity_main 这个布局文件,里面有很多排列组合方式:Linerlayout(线性布局,故名思议就是线性排布,放不下了就会隐藏)。RelativeLayout(相对布局,可以自己用位子调整)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:background="@color/Spalish_backgroundcolor"
    >

其中gravity属性设置了文本相对位置。
如何签名?:Build-Generte-sigined APK-新建一个(别名,钥匙,country code:86,要记住)

3.开始我们的第一个应用程序

如何满足产品需求?
1.有一个页面:SplashActivity活动页面

public class SplashActivity extends Activity {
}

和activity_splash布局文件。用setContentView方法,关联布局文件

 protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //找到对应的布局文件
        setContentView(R.layout.activity_splish);
        }

如何设置最先启动界面?在main文件下有一个灵魂xml文件是AndroidMainfext.xml,可以设置最先启动界面

<application
        android:allowBackup="true"
        android:icon="@mipmap/tp"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">

        </activity>
        <activity android:name=".SplashActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

其中标签块,控制着优先启动界面。

android:icon="@mipmap/tp"

控制软件的图标。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值