Android学习blog
yoyotota · 共 9 篇文章
EditText输入事件截获与监听
本节介绍一下EditText中进行文字截获和事件监听。 预期目标:如下图,输入框中每输入一个字符,下面的TextView可以迅速的显示出来输入框中的内容 1.第一种实现方法:使用setOnKeyListener(),不过这种方式只能监听硬键盘事件 edittext.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { textview.setText(edittext.getText()); return false; …
2011-06-30 12:43 · 评论(1)
个人android笔记(四)
1、ProgressDialog的简单应用: ProgressDialog dialog = ProgressDialog.show(this, "hello", "are you sure???"); new Thread(){ public void run() { try { Thread.sleep(5000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } dialog.dismiss(); }; }.start(); ps:Thread.sl…
2011-06-30 10:18 · 评论(0)
个人android笔记(三)
1、代码片段:获得最新通话记录的时长,格式为HH:mm:ss public String getFormattedTime() { long duration = 0; Cursor cursor = getContentResolver().query(CallLog.Calls.CONTENT_URI, new String[] { CallLog.Calls.DURATION }, null, null, CallLog.Calls.DEFAULT_SORT_ORDER); if (cursor != null) { cursor.moveToPosition(0);//最新的一条 d…
2011-06-28 15:51 · 评论(0)
Activity之间的数据传递_Intent和startActivityForResult的使用
本节主要讨论下Activity之间(A和B)的数据该如何传递。 1、 A->B:A跳转到B的同时,将一些数据传递给B 代码实现:很简单,只需在A中生成Intent的时候,将需要传递的数据放到Intent中,如下:(1)A Intent intent = new Intent(); intent.setClass(A.this, B.class); Bundle bundle = new Bundle(); bundle.putString("story", "Tom&jerry"); intent.putExtra("tag", bundle); startActivity(intent);…
2011-06-28 14:25 · 评论(0)
个人android笔记(二)
1、卸载某一应用,首先应该知道该应用的包名 public static void uninstallApk(Context context, String packageName) { Uri packageURI = Uri.parse("package:" + packageName); Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI); context.startActivity(uninstallIntent); } 2、要设置某个控件的text,使用textview.setText(R.Str…
2011-06-24 10:18 · 评论(0)
个人Android笔记(一)
1、Linkify规则:Linkify.addLinks(tv,Linkify.WEB_URL|Linkify.PHONE_NUMBERS) 2、打电话:Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:" + et.getText())); 3、拨号:Intent intent = new Intent(Intent.ACTION_DIAL); 4、getListView().setTextFilterEnabled(true);//List中允许使用a,b等键盘字母进行快速查询 5、完全退出程序:Android2.2…
2011-06-21 15:47 · 评论(0)
Android平台,如何调用javascript操作网页和js调用系统功能
预期效果:1、java编程实现显示一个网页显示(list,list中有电话号码),网页中的数据内容由程序传过去。 2、点击网页中的电话号码部分,调用手机的打电话界面。 如图: 具体实现: 1、在assets中定义index.html文件,这个文件中table中的数据由javascript生成 ps: (1) contactlist(jsons) 将由java程序调用 (2) onload="javascript:myjavascript.show(): javascript调用java程序,详情见下文 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 T…
2011-06-20 19:04 · 评论(4)
横竖屏切换时候Activity的生命周期
1、新建一个Activity,并把各个生命周期打印出来 2、运行Activity,得到如下信息 onCreate--> onStart--> onResume--> 3、按crtl+f12切换成横屏时 onSaveInstanceState--> onPause--> onStop--> onDestroy--> onCreate--> onStart--> onRestoreInstanceState--> onResume--> 4、再按crtl+f12切换成竖屏时,发现打印了两次相同的log onSaveInstanceState--> onPause--> onStop--> onD…
2011-06-16 18:43 · 评论(0)
[Android实例] android多点触摸demo
MultiTouchActivity package com.zhaokai.multitouch; import android.app.Activity; import android.os.Bundle; import android.view.Window; import android.view.WindowManager; public class MultiTouchActivity extends Activity { /** Called when the activity is first created. */ /** Called when the activity …
2011-06-16 10:43 · 评论(0)