上一页 1 2 3 4 5 6 7 ··· 11 下一页
摘要: //按照垂直顺序排列android:orientation="vertical"android:id —— 为控件指定相应的IDandroid:text ——指定控件当中显示的文字,需要注意的是,这里尽量使用strings.xml文件当中的字符串android:grivity —— 指定控件里面的内容的基本位置,比如说居中,居右等位置android:textSize —— 指定控件当中字体的大小android:background —— 指定该控件所使用的背景色,RGB命名法android:width —— 指定控件的宽度android:height —— 指定控件的高度a 阅读全文
posted @ 2012-01-02 09:33 胖鹅 阅读(219) 评论(0) 推荐(0) 编辑
摘要: 从一个Activity启动到另一个Activity可以使用startActivity()方法或者是startActivityForResult()方法第一种:直接启动一个ActivityIntent intent = new Intent(Main.this, SecondActivity.class);startActivity(intent);第二种:启动另一个Activity并返回结果作用:当从第二个Activity回跳到前一个Activity的时候,就不再需要使用startActivity,也就是说不用两次使用startActivity方法startActivityForResult( 阅读全文
posted @ 2012-01-02 09:30 胖鹅 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 1、Service是一个应用程序的组件2、Service没有图形化界面3、用来处理耗时比较长的功能(下载、播放MP3)4、更新ContentProvider、Intent以及系统的启动Servcie不是一个单独的进程,不是一个线程定义一个Service比较简单,只要继承Service类,实现其生命周期的方法即可。一个定义好的Service必须在AndroidManifest.xml文件中通过<service>声明才能使用<service android:name="MyService"> <intent-filter> <actio 阅读全文
posted @ 2012-01-02 09:27 胖鹅 阅读(252) 评论(0) 推荐(0) 编辑
摘要: 编辑短信的时候,突然接收到电话,通过这种方式可以保存之前已经编辑好的短信内容@Overridepublic void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // 用只读模式打开/data/data/包名/shared_prefs/huangbiao.xml文件 SharedPreferences sharedPreferences = getSharedPreferences("huangbiao", M 阅读全文
posted @ 2012-01-02 09:26 胖鹅 阅读(268) 评论(0) 推荐(0) 编辑
摘要: 将数据直接以文件的形式保存在设备中,通过Context.openFileInput()方法获得标准的JAVA文件输入流(FileInputStream),通过Context.openFileOutput()方法获得标准的JAVA文件输出流(FileOutputStream)写数据到file文件中findViewById(R.id.file).setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { try { //可写入的方式创建或打开huangbiao.txt文件 ... 阅读全文
posted @ 2012-01-02 09:24 胖鹅 阅读(292) 评论(0) 推荐(0) 编辑
摘要: 什么是SeekBar?可以拖动的进度条(在播放器中使用最常见)1、在布局文件中声明<SeekBarandroid:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/seekBar"/>2、定义一个OnSeekBarChangeListener,复写其中的三个方法SeekBar seekBar = (SeekBar)findViewById(R.id.seekBar);seekBar.setOnSeekBarCha 阅读全文
posted @ 2012-01-02 09:21 胖鹅 阅读(223) 评论(0) 推荐(0) 编辑
摘要: JSON作为一种“轻量”的数据结构传递数据,在JS中有广泛的应用Google公司对JSON的解析提供了gson.jar这个包,它不依赖于其他任何JAR包;目前在Android3.0中已经合入了该解析器的功能,但之前的版本是没有的。findViewById(R.id.parseBtn).setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { jsonData = "[{\"name\":\"Michael\",\"age\&quo 阅读全文
posted @ 2012-01-02 09:19 胖鹅 阅读(492) 评论(0) 推荐(0) 编辑
摘要: Timer类,是一种工具,可安排任务执行一次或者定期重复重复执行public class OneTime { public static void main(String[] args) { Timer timer = new Timer(); TimerTask task = new MyTimerTask(); Date date = new Date(System.currentTimeMillis() + 3000); //过三秒之后执行任务 timer.schedule(task, date); }}public class MyTimerTask extends Time... 阅读全文
posted @ 2012-01-02 09:17 胖鹅 阅读(285) 评论(0) 推荐(0) 编辑
摘要: public class IOStreamDemo { public static void main(String[] args) { try { BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("C:\\file_out.txt")); BufferedReader bufferedReader = new BufferedReader(new FileReader("c:\\hb.log")); String tempStr; while((tempStr = bu 阅读全文
posted @ 2012-01-02 09:15 胖鹅 阅读(146) 评论(0) 推荐(0) 编辑
摘要: public class CopyMusic { /* * 以字节为单位读取文件,常用读取二进制文件,如图片、音乐、影像等 */ public static void main(String[] args) { byte[] tempByte = new byte[1024]; int byteread = 0; try { FileInputStream fis = new FileInputStream("c:\\music.wma"); FileOutputStream fos = new FileOutputStream("copy_music.wma&q 阅读全文
posted @ 2012-01-02 09:14 胖鹅 阅读(136) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 11 下一页