Sometimes I really want to know why kids can never focus on doing their homework.

Every time I have to take a lot of time to persuade my son to focus.

I was under more pressure than my son when his midterm exam was coming.

 

*under a lot of pressure:壓力很大

文章標籤

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

We had a long and boring meeting this morning.

When the meeting come to an end , it was almost 1:00 pm. 

As expected, my boss picked on me in the meeting even if I didn't make mistakes.

 

*come to an end:結束

*as expected:不出所料、不意外

文章標籤

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

MainActitvity.java
public class MainActivity extends AppCompatActivity {
    Button m1,m2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        m1=(Button) findViewById(R.id.m1);
        m2=(Button) findViewById(R.id.m2);
    }
    public void ex3(View v){
        Intent in=new Intent();
        in.setClass(MainActivity.this,Ex3.class);
        startActivity(in);
    }
 
Ex3.java
public class Ex3 extends AppCompatActivity {
    Button home2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ex3);
        home2=(Button)findViewById(R.id.home2);
    }
    public void home2(View v){
        Intent in=new Intent();
        in.setClass(Ex3.this,MainActivity.class);
        startActivity(in);
    }
}
 
●再新增一頁Ex3_1,可以回上一頁(Ex3),Ex3新增一按鈕可以跳到Ex3_1
Ex3.java
public class Ex3 extends AppCompatActivity {
    Button home2,ex3_1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ex3);
        home2=(Button)findViewById(R.id.home2);
        ex3_1=(Button)findViewById(R.id.ex3_1);
    }
    public void ex3_1(View v){
        Intent in=new Intent();
        in.setClass(Ex3.this,Ex3_1.class);
        startActivity(in);
    }
Ex3_1.java
public class Ex3_1 extends AppCompatActivity {
Button ex3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ex3_1);
ex3=(Button)findViewById(R.id.ex3);
}
public void ex3(View v){
Intent in=new Intent();
in.setClass(Ex3_1.this,Ex3.class);
startActivity(in);
}
}
(一)設計版面
 
(二)命名id,本金(pv)、 利率(r) 、 年期(n) 、 計算(cal)、 顯示(fv),定義變數和抓id,注意這邊變數的類別有不同
public class Ex3_1 extends AppCompatActivity {
    Button ex3,cal;
    EditText pv,r,n;
    TextView fv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ex3_1);
        ex3=(Button)findViewById(R.id.ex3);
        cal=(Button)findViewById(R.id.cal);
        pv=(EditText)findViewById(R.id.pv);
        r=(EditText)findViewById(R.id.r);
        n=(EditText)findViewById(R.id.n);
        fv=(TextView)findViewById(R.id.fv);
    }
...
}
 
(三)寫函式
public class Ex3_1 extends AppCompatActivity {
   ...(前面省略)
    public void cal(View v){
        int PV=Integer.parseInt(pv.getText().toString());
        double R =Double.parseDouble(r.getText().toString()) ;
        int N=Integer.parseInt(n.getText().toString());
        fv.setText("複利本利和="+PV*Math.pow((1+R),N));
    }
}
**說明:
1.在android抓輸入資料和輸出資料一樣用getText()和setText()
2.但pv.getText()抓回來不是String而是Edittext類型,如下圖,要用toString()把Edittext轉成字串( toString()可以把所有非字串的物件轉成字串)
3.但因為還要把輸入的資料拿來計算,所以要再轉成int和double,做法和java完全一樣
 
*衍生練習(github黨):躉繳保費的內部報酬率計算
文章標籤

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

●(一)新增一個按鈕,點擊可以直接連到goolge網址
**(Action_view,uri)
1)瀏覽器=>Http://
2)電話=>tel:
搭配uri物件
 
1.介面設定button(大小字型等),指定id(btnGoogle)和函式名稱(btnGoogle)
2.定義變數,抓id,寫功能
public class Ex2 extends AppCompatActivity {
    Button home1,btnGoogle;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ex2);
        home1=(Button)findViewById(R.id.home1);
        btnGoogle=(Button)findViewById(R.id.btnGoogle);
    }
    public void home(View v){
        Intent in=new Intent();
        in.setClass(Ex2.this,MainActivity.class);
        startActivity(in);
    }
    public void btnGoogle(View v){
        Uri google=Uri.parse("http://www.google.com.tw");
        Intent in=new Intent(Intent.ACTION_VIEW,google);
        startActivity(in);
    }
}
**說明:
1.要先產生uri物件, Uri google=Uri.parse("http://www.google.com.tw");=>透過google(可隨意定)轉成Uri物件,因為Uri是static所以不用new,parse()=>是把字串轉成uri物件類型的方法
2.我們要用的是 Intent(Intent.ACTION_VIEW,google);=>這是Intent的建構式, ACTION_VIEW,前面的 ACTION是動作, _VIEW,是要做的功能
 
(二)增加一個撥電話的按鈕
public class Ex2 extends AppCompatActivity {
    Button home1,btnGoogle,btnTel;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ex2);
        home1=(Button)findViewById(R.id.home1);
        btnGoogle=(Button)findViewById(R.id.btnGoogle);
        btnTel=(Button)findViewById(R.id.btnTel);
    }
    public void btnTel(View v){
        Uri tel=Uri.parse("tel:21345678");
        Intent in = new Intent(Intent.ACTION_DIAL,tel);
        startActivity(in);
    }
 .....(下面程式與上面同先省略)
}
**說明:
1.先定義變數,抓id
2.這邊撥電話在parse中要輸入("tel:....")=>大小寫都可以
3.action要選擇ACTION_DAIL
 
(三)增加一個啟動相機的按鈕
public class Ex2 extends AppCompatActivity {
Button home1,btnGoogle,btnTel,btnCam;
 
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ex2);
home1=(Button)findViewById(R.id.home1);
btnGoogle=(Button)findViewById(R.id.btnGoogle);
btnTel=(Button)findViewById(R.id.btnTel);
btnCam=(Button)findViewById(R.id.btnCam);
}
public void btnCam (View v){
Intent in=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivity(in);
}
...
}
**說明:
1.開啟相機要用 MediaStore.ACTION_IMAGE_CAPTURE
2.這次用到的建構式為Intent(String action),只放一個action當引數
 
(四)增加一個啟動設定好位置的google map
public class Ex2 extends AppCompatActivity {
    Button home1,btnGoogle,btnTel,btnCam,btnMap;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ex2);
        home1=(Button)findViewById(R.id.home1);
        btnGoogle=(Button)findViewById(R.id.btnGoogle);
        btnTel=(Button)findViewById(R.id.btnTel);
        btnCam=(Button)findViewById(R.id.btnCam);
        btnMap=(Button)findViewById(R.id.btnMap);
    }
    public void btnMap(View v){
        Uri map=Uri.parse("geo:25.096275, 121.516642");
        Intent in=new Intent(Intent.ACTION_VIEW,map);
        startActivity(in);
    }
**說明:
一樣使用Uri.parse(),但裡面放geo:緯度,經度,同樣使用ACTION_VIEW
 
*衍生練習(github):ACTION_VIEW的實作練習
 
文章標籤

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

 
●實作:做兩個頁面切換,第一頁是MainActivity,有一個按鈕(id=m1),可以切換到第二頁有主題內容+一個button(id=home1)可以切回首頁
 
1.先設定首頁的按鈕ID(m1)和onClick函式名稱(ex2),並調整按鈕文字內容和大小
 
2.宣告變數,抓id(記得轉型),先建立onClick函式外面
public class MainActivity extends AppCompatActivity {
    Button m1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        m1=(Button) findViewById(R.id.m1);
    }
     public void ex2(View v){
 
     }
}
 
3.開新的activity=>Ex2,抓版面,文字要用text view,這邊text view因為沒有要在java程式中用到,可以不用給id
 
4.onClick函式給名稱,寫程式碼指定變數和函式
public class Ex2 extends AppCompatActivity {
Button home1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ex2);
}
public void home(View v){
}
}
 
 
5.撰寫兩個java的onClick method,測試
MainActivity.java
public void ex2(View v){
    Intent in=new Intent();
    in.setClass(MainActivity.this,Ex2.class);
    startActivity(in);
}
 
Ex2.java
public void home(View v){
    Intent in=new Intent();
    in.setClass(Ex2.this,MainActivity.class);
    startActivity(in);
}
**說明:
1.因為Intent的功能都沒有static,所以一定要new
2.startAcitvity(in)=>啟動Intent物件(in)
3. setContentView(R.layout.activity_ex2); 代表要去R下面找一個class layout裡面的activity_ex2.xml的內容給java檔,所以如果這個 activity_ex2位置指定錯會有問題,如果整行都被刪掉,整個頁面都會空白,因為抓不到xml的內容
 


=====================其他功能說明=======================
 
●Activity和xml彼此都無法理解對方的內容,透過R.java(資源檔)去連結
=>xml元件java看不懂,所以所有的原件都註冊在R.java,這個檔會記住所有元件並給一個位址代號,當Activity.java要使用元件時,就會去找這個元件的編碼(序號)
 
●如果要查api,可以到官網直接搜尋reference
 
●要import的時候,可以直接用精靈,如下例,要import Button,先在下面打But打到一半精靈會跳出來,選擇正確的路徑
 
=>就會自動帶出import路徑=>import android.widget.Button;
 
●做好在手機安裝測試後,就會在C:\Java\17\App_2\app\build\outputs\apk路徑下產生一個.apk檔,這就是可以給別人使用的安裝檔
文章標籤

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

I took a lot of time to prepare the Chinese question paper for my son yesterday.

Finally, my husband find a software that could produce all kinds of question paper and that really helped me saved my time.

However, my son still didn't review his exam util 4:30 and I really worried about his exam.

 

文章標籤

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

其實我 有一個小小的夢想,就是希望有一天可以和兒子手牽手,

一起去圖書館看書,兩個人各拿一本書,

坐在圖書館悠閒地度過一個早上!!

所以一直想讓兒子養成看書的好習慣,

從他出生沒多久就一直想買書給他看!!

而且我也發現現在好多爸媽都很積極培養小孩的閱讀習慣...

兒子學校的同學也都很愛看書,

大家吃完點心都會自己去拿書來看!

好在皇天不負苦心人,

兒子現在也養成沒事做會自己去拿書來看的習慣了!!

莫名的感動捏!!

為了讓兒子能一直有新書可以看,

又不用花大錢狂買繪本(繪本價格真的不便宜呀!!)

當然要善用圖書館了!!

感謝新北市各大圖書館超級方便書又多,尤其是台灣圖書館!!

有兒童專屬的圖書館真的是太棒了!!

不過因為有時候也不知道那些書好看,

所以就參考閱讀起步走計畫的建議書單(請點我)

這些書在圖書館都非常熱門,不過可以善用預約功能,

來分享一下兒子特別喜歡的書!!

=============以上是題外話的分隔線================

這本書真的很可愛,是一隻小兔子的故事!

構圖非常簡單易懂,但是可以激發小朋友的想像力!!

dscn2538-e1555214317685.jpg

在大人眼中的紙箱,在孩子的世界裡看到的是甚麼呢?

為什麼小兔子要用水噴箱子呢??

dscn2539-e1555214332898.jpg

因為這不是箱子呀,是.....失火的高樓大廈!!

dscn2540-e1555214345405.jpg

把拔馬麻看到小兔子坐在箱子裡,問他為什麼要坐在箱子裡呢??

dscn2541-e1489668332163.jpg

因為這不是箱子...是.....(不言而喻囉!!)

dscn2542-e1555214365332.jpg

每一頁都是一個想像一個創意,

我想每個大人在還是孩子的時候可能也都擁有這樣的想像力與創造力吧!!

只是隨著年紀漸長就慢慢淡忘了這樣的樂趣。

(想起兩年多前幫兒子做的超隨便的紙箱屋子,他還是玩得很開心!!)

dscn0676-e1555214378557.jpg

 

這本書兒子(大概3Y11M)非常喜歡呢,講一次隔天就自己拿著一直看,

我講的時候也因為覺得很有趣一直傻笑!!

 

推薦這本書的主要原因:

構圖簡單,內容前顯易懂,即使沒講過小孩也可以自己看得懂,

講過一次以後自己閱讀不成問題!!可以增加小孩願意自己閱讀的意願!!

內容非常貼近小孩子的想法與遊戲方式,兒子覺得很有趣會想一看再看!

 

文章標籤

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

After my son's taekwondo class, we went to Costco to buy the book  "The Secret World of  Arrietty" and we'd like to eat lunch at Costco.

However, we could not only not find the book but also waited for a long time for eating our lunch because there were a lot of people wanting to eat lunch at Costco.

My son didn't review for his midterm exam until 4:30 pm.

 

*The Secret World of  Arrietty:借物少女艾莉緹

文章標籤

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

I asked my son about his exam yesterday and he thought he did well on the exam.

Everytime after talking with my boss, I feel angry and frustrated.

Sometimes I really envy people who are single because they have enough time to do what they want to do and they don't have to worry about their child.

文章標籤

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

●實作練習
=>首頁有intent button點了會換頁,換頁後有home button在跳回首頁
 
1.同一個專案開第二頁=>左邊專案按右鍵,
new=>activity=>empty activity,取名為intent,一次產生兩個檔案
intent.java/activity_intent.xml
 
2.在main.xml的intent button修改變數名稱(ID)btnIn,
再給onclick一個函數名稱BtnIn=>android中的變數名稱就是ID
 
3.切到main的activity,寫程式碼
public class MainActivity extends AppCompatActivity {
    Button btnIn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btnIn = (Button) findViewById(R.id.btnIn);
    }
 
    public void BtnIn(View v) {
        Intent in = new Intent();
        in.setClass(MainActivity.this,intent.class);
        startActivity(in);
    }
}
**說明:
1.先定義一個Button物件,這邊定義的變數名稱可以和ID同名
2.初始化 (即把R.java中元件的位置指給變數btnIn)
=> btnIn = (Button) findViewById(R.id.btnIn); 
=>把Button物件和btnIn這個按鈕在啟動時掛在一起,但因為是用View找到的(類型為View),如果前面沒有加上(Button)去做轉型,就會出現如下錯誤訊息
3.寫onclick函式public void Btnln(View v){}
=>因為是由View抓來的,所以在等View的訊息傳來再執行這個method
4. Intent in = new Intent();
=>new 一個Intent物件,Intent可以用來換頁(指從一個.java換到執行另外一個.java,亦即從一個*.class換到另一個 *.class檔)
5.換頁要使用Intent的setClass()方法,要帶入兩個引數(本身的class,要切換過去的class檔)
=>本身的寫法: MainActivity.this;要切換過去的class檔為:intent.class
6. startActivity(in);=>用這個方法啟動Intent
 
**注意:
1.如果自己的作的class檔名和Intent物件名稱相同,在new Intent物件的時候要注意路徑指向是否正確,不然會new到自己的class檔
2.假設完成後run一直閃退(閃退就是Exception強迫中斷的結果),檢查View有沒有抓到,另外檢查ID或onclic的函式名稱是否有寫錯(大小寫要完全一樣),因為這邊只設定了兩個名稱
文章標籤

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