Categories
Android

一个封装 android.util.Log 的Log类

在android代码的每个Activity,都不厌其烦的写: private static final String TAG = “MyActivity”; 然后需要打印的地方输入: Log.v(TAG, “index=” + i); 写太多的TAG,也麻烦,如果不写TAG,用 this.toString() 也可行,不过还是一样,于是写个包装Log类,自动处理是哪个Activity,调用哪个函数,如下: /* * Copyright (C) 2010 Lytsing Huang http://lytsing.org * * Licensed under the Apache License, Version 2.0 (the “License”); * you may not use this file except in compliance with the License. * You may obtain a copy of […]

Categories
Android

Protocol Buffers in Android

Protocol Buffers in Android 无意中看到android market调试Log信息:”Lcom/google/common/io/protocol/ProtoBuf;”, 觉得好奇,搜索一下,ProtoBuf其源代码位于 external/protobuf/src/com/google/common/io/protocol,这个可不同于com.google.protobuf 包,后者是Google标准官方实现,com.google.common.io.protocol是Android平台上的,提供的接口,可以在这里查阅 http://www.androidjavadoc.com/m5-rc15/com/google/common/io/protocol/ProtoBuf.html 在 cupcake源代码目录下搜索ProtoBuf,没有找到使用ProtoBuf的相干代码。目前我发现只有android market使用这个库,market的数据交换格式不是什么xml或json,当然采用Google自家发明的Protocol Buffers。 update: 2010/08/19: 下载了 Android 2.2的代码,发现external/protobuf/目录不见了,被整进了 GoogleServicesFramework.apk 这个包,美曰其名: Google 服务框架。

Categories
Android

How to Use Android Downloads Provider

“Good programmers write solid code, while great programmers reuse the code of good programmers” — W. Jason Gilmore, the author of “Beginning PHP and MySQL” In Android Platform, it supports some ways to download files from URLs via HttpURLConnection or HttpClient, or DownloadProvider.When you write an android programm with Eclipse, try to import: import android.provider.Downloads […]

Categories
Android

如何学习Android应用程序的开发

昨天一同学问我,如何快速的学习Android应用程序开发? 之前的一位同事也问过我,我也只是大概的说说看哪些资料。为避免更多的人问我,所以有必要写写。 1. 开发环境搭建。自行Google。英文好的,看官方网 http://developer.android.com/ 访问不了的,可以访问它的镜像 http://androidappdocs.appspot.com/index.html 2. 在模拟器上运行 ApiDemos,全部点一遍,看看Android都提供了些什么界面效果,心里有个印象。最好把ApiDemos的代码,看它个两三遍。我到过深圳南山书城,看了好几本国内出的Android书籍,一本书都没翻多久,就看完了,没啥看头,因为大部分内容ApiDemos都有了呀。 3. Java的学习。 Android应用程序是用Java写的,像我这样从C/C++阵营过来的,开始真的很抵触。《Thinking in Java》 ??? No! 没时间玩这东西,当做参考书还行,不懂就翻翻。宝岛台湾的林信良老师写的《Java学习笔记》,还不错。 http://caterpillar.onlyfun.net/Gossip/JavaGossip-V1/JavaGossip.htm http://caterpillar.onlyfun.net/Gossip/JavaGossip-V2/JavaGossip2.htm 大约花一个礼拜的晚上时间学习,基本够用。 4. 学习资料 (1) 网站 官网 developer.android.com,英文差的同学,也要硬着头皮看,在网上搜来搜去,其实大部分东西都是从这拷贝过去的,从而浪费了大把的时间。国内的android论坛,好像就javaeye文章质量高一点,其他的不知道。我一直上国外的 http://www.anddev.org/ 它有两个版面 Novice Tutorials和Code Snippets for Android,有教程,可以下载代码编译运行,初学者最喜欢这样的了。不像一些网站,下载代码还要扣积分等其他7788的,一看就没什么好感。 (2) 书籍 就只推荐三本,其他的没看过,不好评论。 Mark L. Murphy: 《The Busy Coder’s Guide to Android Development》 Chris Haseman:《Android Essentials》 高煥堂:《Android 應用框架原理與程式設計36 技》 初学者最好不要第一本书就看高的书,因为一些东西他讲起来莫名其妙,搞复杂了,一看developer.android.com英文原版的资料,噢!英文描述这么简单啊。 (3) […]

Categories
Android

Android Market的 Loading效果

在Android中,要实现Loading效果,一般情况下都使用ProgressDialog控件。ApiDemos/src/com/example/android/apis/view/ProgressBar3.java 提供两个demo: 仔细看了Android Market,发现却是不一样的,请看截图: 那到底如何实现呢?首先,我们创建一个布局文件, res/layout/fullscreen_loading_indicator.xml, 其内容如下: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:gravity=”center_vertical|center_horizontal” android:orientation=”horizontal” android:id=”@+id/fullscreen_loading_indicator” android:visibility=”gone” android:layout_width=”fill_parent” android:layout_height=”fill_parent” > <ProgressBar android:layout_gravity=”center_vertical” android:layout_width=”wrap_content” android:layout_height=”wrap_content” style=”?android:attr/progressBarStyleSmall” > </ProgressBar> <TextView android:id=”@+id/current_action” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_marginLeft=”5.0dip” android:text=”@string/loading” > </TextView> </LinearLayout> 然后在main.xml 把它include 进来 <?xml version=”1.0″ encoding=”utf-8″?> <FrameLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”fill_parent” > <LinearLayout android:orientation=”vertical” android:id=”@+id/main_info” android:visibility=”gone” android:layout_width=”fill_parent” android:layout_height=”fill_parent” > </LinearLayout> <include […]

Pages: Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 Next