安卓第一行代码总结(一)

一、对Android的了解
1、Android的系统架构–是基于Linux开发的操作系统。
a、 Linux内核层
b、 系统运行库层
c、 应用框架层
d、应用层
2、关于日志(Log)工具
a、为什么在Android中不用System.out.println()?
原因是于Log相比它在日志打印是不可控制,打印时间无法确定,不能添加过滤器。。。。
b、在写Log的技巧(在输入logt后按Tab键可以可以生成一个常量。)

3、AndroidManifest.xml清单文件的解析:
<?xml version="1.0" encoding="utf-8"?>
<!--该包名用于唯一的该应用-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.exa<?xml version="1.0" encoding="utf-8"?>
<!--该包名用于唯一的该应用-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.jcs.myone">
    <!--allowBacku指的应用程序是否允许备份-->
    <!--supportRtl指的是有一个强制使用从右到左的布局方向-->
    <!--theme指定自己的主题-->
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <!--指定该activity是程序的入口-->
                <action android:name="android.intent.action.MAIN" />
                <!--指定加载该应用时运行该Activity-->
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
mple.jcs.myone">
    <!--allowBacku指的应用程序是否允许备份-->
    <!--supportRtl指的是有一个强制使用从右到左的布局方向-->
    <!--theme指定自己的主题-->
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <!--指定该activity是程序的入口-->
                <action android:name="android.intent.action.MAIN" />
                <!--指定加载该应用时运行该Activity-->
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
2、当一个界面销毁时把数据返回给上一个页面
首页:StartActivityForResult(intent,请求吗);
下一个:用setResult(RESULT_OK,intent)
首页:重写onActivityResult(请求码,返回传入的结果值(RESULT_OK),intent)
Switch判断返回的是哪个请求码在判断传回来的处理结果后获得intent值。
3、禁用转化为写的特性:android:textAllCaps="false"
4、imageview中改变图片:imageView.setImage Resource(R.mipmap.image);
5、进度条:ProgressBar
隐藏和显示切换:if (progressBar.getVisibility() == view.GONE) {
    progressBar.setVisibility(view.VISIBLE);
} else {
    progressBar.setVisibility(view.GONE);
}
6、获取和设置值:int propess = progressBar.getProgress();
propess = propess + 10;
progressBar.setProgress(propess);
7、设置样式:style="?android:attr/progressBarStyleHorizontal"/
8、AlertDialog警告对话框: AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this);
dialog.setTitle("Hello");
dialog.setMessage("你是傻逼?");
dialog.setCancelable(false);//按返回键是否可以撤销(true可以,false不可以)
dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialogInterface, int i) {

    }
});
dialog.setNegativeButton("Exit", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialogInterface, int i) {

    }
});
dialog.show();
9、进度条对话框:ProgressDialog dialog = new ProgressDialog(MainActivity.this);
10、LinearLayout: android:layout_width="0dp"
android:layout_weight="2"//平分。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值