Time of Update: 2018-12-05
Android TahHost的使用,這裡採用繼承TabActivity的方法。這裡分別定製三個Tab,分別為american.xml, chinese.xml, japanese.xml三個Layout。american.xml檔案<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
Time of Update: 2018-12-05
項目的結構首先建立一個book_info.xml的xml檔案,結構如下:<?xml version="1.0" encoding="UTF-8"?><books> <catalog>Computer</catalog> <book> <country>USA</country> <title>Empire Burlesque</title>
Time of Update: 2018-12-05
Android Notication的使用private void sendNotification() {// TODO Auto-generated method stubNotificationManager manager = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);Notification notification = new
Time of Update: 2018-12-05
Layout的設計,其實有我這裡直接拖了一個TabHost控制項,然後在每個Tab中放一個Button。檔案名稱為activity_tab_host.xml.<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
Time of Update: 2018-12-05
Android 自訂View為MyCustomView。在MyCustomView畫了一個Rect,顏色為Green,和一個為紅色的文字。public class MyCustomView extends View{ private Paint mPaint; private Context mContext; private static final String mString = "Hello world!"; public
Time of Update: 2018-12-05
Android 資源的使用一、dimension資源的使用Android中dimension單位有: px 像素 dp 密度 mm 毫米 pt 點 sp 刻度 in英寸dimension資源的定義<resources> <!-- Default screen margins, per the Android Design guidelines. --> <dimen name="activity_horizontal_margin">1
Time of Update: 2018-12-05
Android ExpandableListView的使用一、MainActivity要繼承ExpandableListActivity。效果是當單機ListView的子項是顯示另一個ListView。public class MainActivity extends ExpandableListActivity {private static final String NAME = "NAME";private static final String IS_EVEN =
Time of Update: 2018-12-05
Android中ExpandableList的使用2本文介紹Android中ExpandableList的使用,在前文的基礎上作了很多改進,增加了增加、刪除、回調等功能。圖中的 “第一行班組號: 1 軟體工程2班”是要顯示的資訊。先看: 首先定義一個含有ExpandableListView的Layout。還有一個是顯示的文本資訊。<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
Time of Update: 2018-12-05
An image with higher resolution does not provide any visible benefit, but still takes up precious memory and incurs additional performance overhead due to additional on the fly scaling. Given that you are working with limited memory, ideally you
Time of Update: 2018-12-05
Android 檔案操作操作時,要賦予相應的許可權: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 下面是向檔案寫文本的代碼: private final static String PATH = "/sdcard/lin";private final static String FILENAME =
Time of Update: 2018-12-05
android 匯入項目 項目中文字亂碼問題 原文地址亂碼問題出現了幾次,一直沒有在意,今天又出現了,現總結如下:eclipse之所以會出現亂碼問題是因為eclipse編輯器選擇的編碼規則是可變的。一般預設都是UTF-8或者GBK,當從外部匯入的一個工程時,如果該工程的編碼方式與eclipse中設定的編碼方式不同,就會產生中文的亂碼問題,這其中還有幾種情況。如果匯入的整個工程的編碼方式與eclipse的編碼方式有衝突,那麼這個工程裡所有的中文
Time of Update: 2018-12-05
將android:screenOrientation="portrait",轉換橫屏豎屏無效,始終顯示豎屏。 <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" >
Time of Update: 2018-12-05
Android中的TableLayout的簡單使用在Layout中加入TableLayout控制項。 <TableLayout android:id="@+id/myTableLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="40dp"
Time of Update: 2018-12-05
Android 連絡人資訊的擷取public class MainActivity extends Activity {String id, name, phoneNumber, email;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);ContentResolver
Time of Update: 2018-12-05
ubuntu下android環境配置1. JDK的安裝,我安裝的是JDK6,詳細見Ubuntu 中JDK的安裝總結2. 下載Eclipse直接下載一個linux版本的eclipse運行Eclipse, 點擊 Help > Software Updates > Available Software。點擊“Add site..”按鈕然後在裡面輸入 https://dl-ssl.google.com/android/eclipse/
Time of Update: 2018-12-05
Android 將Activiyt作為Dialog彈出在Androidmanifest.xml中加入如下主題 <activity android:name="com.example.mymeidaplay.Player" android:theme="@android:style/Theme.Dialog" > </activity> 在作為Dialog的Activity中做如下設定:
Time of Update: 2018-12-05
使用ListView在setAdapter()後,對ListView的childView做一些操作。但是每次要取得childCount總是0。原來setAdapter是非同步(asynchronous)。只要在setAdapter()之後,加入post函式去更新ListView的ChildView即可。 lv = (ListView)findViewById(R.id.list); lv.setAdapter(adapter); lv.post(new Runnable(){
Time of Update: 2018-12-05
Android開發中,當需要建立在後台啟動並執行程式的時,就要用到Service。Service跟Activities是不同的(可以理解為後台與前台的區別),啟動Service過程如下:context.startService() ->onCreate()- >onStart()->Service running其中onCreate()可以進行一些服務的初始化工作.停止Service過程如下:context.stopService() | ->onDestroy() -
Time of Update: 2018-12-05
這幾天沒有來得及更新部落格,有兩個原因,一個是個人的私事比較忙,另外就是應basic4android 作者的邀請,把basic4android的介紹和教程翻譯成中文。前年開始做android開發,由於過去一直使用delphi 開發,習慣了可視化設計,實在不太習慣使用Java 開發,剛好有個國外的朋友介紹了basic4android, 當時basic4android還是beta 測試階段,經過測試就發現basic4android除了使用visual
Time of Update: 2018-12-05
從事開發近六年了,接觸Android開發也半年多了,絕不敢稱牛人,因為牛人還大有人在。部落格園的帳號開到現在還是沒寫過一篇像樣的,當初開的時候就是打算寫點什麼,以回報這些年在網上搜尋的資料,因為如果人人都只搜尋不貢獻那大家也不會搜到那麼好的文章了。 廢話少說了,這是第一次寫技術帖,不及之處,還望包涵。牛人就免進了,因為從最簡單的講起的,就當是給自己這一段的學習做一次回顧吧!從經典的Hello World!