android学习零碎笔记

android 学习
*******************************
1.findViewById    null错误
____________________________________________
   1. if you use xml based layout, you must add this line before run findViewById.
      setContentView(R.layout.main);
   2. the id that you can use is only the id that define on your layout for each activity. To check the id you can 

     find it on R class
   3. remember to use complete android:id to define an id to a view

2.menu (android.view.Menu)
______________________________________________
   1. add(groupid,id,orderid,charsequence)
  



3.onOptionsItemSelected(MenuItem item)   和 onCreateOptionsMenu(Menu menu)对应
______________________________________________
   menu.add();
   MenuItem item是menu 里add进去的

4.alertDialog 弹出框
______________________________________________
 new AlertDialog.Builder(this)
                  .setMessage(R.string.msg_dialog)
                  .setTitle(R.string.promote_dialog)
                  .setIcon(R.drawable.icon)
                  .setNeutralButton("Close",
                          new DialogInterface.OnClickListener(){
                       public void onClick(DialogInterface dlg,int sumthin){                       
                       }
                      })
                   .show();
5
______________________________________________
options menu就是通过按home键来显示,context menu需要在view上按上2s后显示。这两种menu都有可以加入子菜单,子菜单不能

种不能嵌套子菜单。options menu最多只能在屏幕最下面显示6个菜单选项,称为icon menu,icon menu不能有checkable选项。多

于6的菜单项会以more icon menu来调出,称为expanded menu。options menu通过activity的onCreateOptionsMenu来生成,这个函

数只会在menu第一次生成时调用。任何想改变options menu的想法只能在onPrepareOptionsMenu来实现,这个函数会在menu显示前

调用。onOptionsItemSelected 用来处理选中的菜单项。

context menu是跟某个具体的view绑定在一起,在activity种用registerForContextMenu来为某个view注册context menu。context

menu在显示前都会调用onCreateContextMenu来生成menu。onContextItemSelected用来处理选中的菜单项。


6 Intent
______________________________________________
Intent intent=new Intent(Intent.ACTION_DIAL);
//intent.setClassName("com.demo", "com.demo.TestActivity");                 
startActivity(intent);
以上实例化一个intent 然后在AndroidManifest.xml中指定接收者,也就是多个action
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.DIAL" />

<activity android:name=".SimpleIntentTest"

                  android:label="@string/app_name">

            <intent-filter>

                <action android:name="android.intent.action.MAIN" /><!--指定接受者1-->
                <action android:name="android.intent.action.DIAL" /><!--指定接受者2-->
                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>
</activity>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值