目前分類:來玩Android (56)

瀏覽方式: 標題列表 簡短摘要

本文原始出處為 http://blog.csdn.net/guolindonggld/article/details/24243059

getApplication();

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

使用Android Studio開啟一個新專案,它會預設幫你建立幾個資料夾,用處說明如下

manifests  記錄應用程式的細節定義,資料夾裡面會有個AndroidManifest.xml,內容包含套件名稱,元件名稱及權限設定等

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

資料來源 http://jashliao.pixnet.net/blog/post/222652314  https://developer.android.com/reference/android/view/KeyEvent.html

Summary

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

參考自 https://github.com/vanevery/JavaCV_0.3_stream_test

參考自 https://github.com/bytedeco/javacv/blob/master/samples/RecordActivity.java

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

在Android Studio的做法是

1.在res按滑鼠右鍵->NEW->Directory ,來新增一個目錄,這個目錄的命就依下面的語系自行選擇.

文章標籤

痞客興 發表在 痞客邦 留言(1) 人氣()

Android中如果需要與使用者互動或者儲存輸入資料時,通常會用EditText這個元件來達成.

但這就牽扯到了一些問題,如果使用者沒有按照規劃輸入應該輸入的資料時,你的APP要怎麼反應呢??

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

lv1 = (ListView)findViewById(R.id.lv1);

db = openOrCreateDatabase("db1.db",MODE_PRIVATE,null); 
Cursor cursor = db.rawQuery("select _id, name, phone from mytable",null);

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

建立Database

SQLiteDatabase db = openOrCreateDatabase("mydb.db",MODE_PRIVATE,null);
第二個參數可以用
MODE_PRIVATE
MODE_WORLD_READABLE
MODE_WORLD_WRITEABLE

刪除Database

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

權限的開放,在AndroidManifest.xml加入

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

MainActivity.java

package tw.idv.charleslin74.sdcardreadwritetest;
import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
    @Override
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView showerror = (TextView) findViewById(R.id.showerror);
        String aaa = Environment.<em>getExternalStorageDirectory</em>().getPath();
        showerror.setText(aaa);
    }
}

activity_main.xml

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

寫入資料

FileOutputStream fout = openFileOutput("myfile.txt",MODE_PRIVATE);
BufferedOutputStream buffout = new BufferedOutputStream(fout);
buffout.write("這是測試".getBytes());
buffout.close();

讀取資料

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

寫入資料

SharedPreferences spToDo = getSharedPreferences("prefile",MODE_PRIVATE);
spToDo.edit().putString("username","superman").commit();

放進資料的方式有putBoolean,putFloat,putInt,putLong,putString,依需求自已改變.

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

package com.example.charleslin.keybackalarm;

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

有時我們在頁面裡放的內容,有可能會超過頁面所能承載,這時就必須用到第二個頁面來顯示.

但你可以試試,android就只顯示第一個頁面,其他的內容你是看不到的.

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.charleslin.playlivevideo" >
    <uses-permission android:name="android.permission.INTERNET" >
    </uses-permission>
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:configChanges="orientation|screenSize" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".VideoViewActivity"
            android:configChanges="orientation|screenSize" >
        </activity>
    </application>
</manifest>

MainActivity.java

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

如果你的APP是一個靜態頁面的話,它想刷新就讓它刷新,但是如果你頁面的資料是來自網路上或者你正在看影片聽音樂,轉個螢幕就重新看重新聽,你不被使用者打死才怪.

那為什麼轉個螢幕就必須重新開始呢??

痞客興 發表在 痞客邦 留言(0) 人氣()

基本的JSONObject,key和value間是用:隔開的
{"door":"red"}

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

AndroidManifest.xml裡要開放對INTERNET的存取權限
<?xml version="1.0" encoding="utf-8"?>
文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

1 23