1.android:label指定活动中标题栏的内容,标题栏是显示在活动最顶部的。给主活动指定的label不仅会成为标题栏中的内容,还会成为启动器中应用程序显示的名称
2.intent-filter中加action,category,作为主活动,如果应用程序中没有声明任何一个活动是主活动,这个程序仍然是可以正常安装的,只是你无法在启动器中看到或者打开这个程序。这种活动一般都是作为第三方服务供其他应用在内部进行调用,如支付宝快捷服务
3.隐藏标题栏,requestWindowFeature(Window.Feature_No_Title);
4android:theme=@android:style/Theme.Dialog 让当前Activity使用对话框的主题
5.活动的启动模式 通常在<activity>标签下指定android:launchMode属性
6.知晓当前活动Activity/Fragmen在哪个活动。在BaseActivity/Basefragment的oncreate()方法中
Log.d("base",getClass().getSimpleName());
7.EditText最大行数为两行 设置 android:maxLines="2"
8.ProgressBar的使用
此为水平的
<ProgressBar android:id="@+id/pb_progress" style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:max="100" />
点击按钮进度条增长10,总共100
int progress = pb.getProgress(); progress += 10; pb.setProgress(progress);8.AleartDialog的使用,点击按钮弹出对话框
AlertDialog.Builder dialog = new AlertDialog.Builder(aActivity.this); dialog.setTitle("This is a Dialog"); dialog.setMessage("Something important..."); dialog.setCancelable(false);//dialog能不能通过back键取消 dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); dialog.setNegativeButton("Cancle", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); dialog.show();9.点击按钮弹出PrigressDialog
ProgressDialog progressDialog = new ProgressDialog(aActivity.this); progressDialog.setTitle("This is ProgressDialog"); progressDialog.setMessage("Loading"); progressDialog.setCancelable(false);//表示不能通过back键取消,代码中当数据加载完调用ProgressDialog的dismiss()来关闭,否则一直在 progressDialog.show(); }10. RelativeLayout中子控件的属性
android:layout_above/below="@id/btn**"
android:layout_toRightOf="@id/btn**"
EditText属性 android:inputType="TextPassword"
TableLayout中Table下控件属性 android:layout_span="2"占两列
TableLayout中让指定列拉伸 android:strechColumns=“1” 第二列
android:background用于为布局或控件指定背景,可用颜色或图片进行填充
11.引入布局
例如写好一个标题栏布局 左右各一按钮,中间文本。其他xml布局引入时
<include layout=@layout/title/>
而back键基本都为返回,每次写重复,自定义控件(记得用时指明完整类名)
在布局中引入自定义的控件调用两个参数的构造函数
12.在一个布局中引入TitleLayout时,返回按钮跟编辑按钮的点击事件已经自动实现好了
public class TitleLayout extends LinearLayout { public TitleLayout(Context context, AttributeSet attrs) { super(context, attrs); LayoutInflater.from(context).inflate(R.layout.title, this); findViewById(R.id.title_back).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ((Activity) getContext()).finish(); } }); findViewById(R.id.title_edit).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getContext(),"you clicked Edit button",Toast.LENGTH_SHORT).show(); } }); } }