摘要: 元旦放假三天,天气很冷没有打算出去玩,就在家里琢磨着弄一下扒网站新闻,主要是同寝室的一个同事在弄,所以想学点东西,自己也动手写了一个,思路很简单,下面就描述一下是怎么实现的吧!首先进入主页网站中,然后选择自己想“扒”的信息模块,例如是新闻、经济、娱乐等等或者其他什么的,这样就能找到自己需要信息,然后把这个模块的url链接地址给读取出来,然后遍历读取到的URL地址,读取信息的内容。现在的网站一般都是动态生成的,也就是说新闻信息页面有自己的模板,那么所有的信息肯定是在某个DIV或者是容器中,只要找到这个控件的ID就能够得到里面的数据,然后把里面的数据找出来。下面的代码是我测试了某网站的信息,已经读 阅读全文
posted @ 2012-01-02 18:12 胖鹅 阅读(265) 评论(0) 推荐(0) 编辑
摘要: //按照垂直顺序排列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) 编辑
摘要: public class FileAndDir { public static void main(String[] args) { //现在只是在内存中,既不是文件也不是目录 File file = new File("c:\\hb"); File dir = new File("c:\\dir"); try { //创建了一个空文件 file.createNewFile(); if(file.isFile()){ System.out.println("isFile"); } //创建了一个目录 dir.mkdir(); if(d 阅读全文
posted @ 2012-01-02 09:10 胖鹅 阅读(152) 评论(0) 推荐(0) 编辑