教材訂閱頻道:杜仲教學YouTube
https://www.youtube.com/channel/UCElwt6s8Ea_V-gnu9sZZT5g?sub_confirmation=1
Pionex 派網程式交易: https://www.pionex.com/zh-TW/sign/ref/RnoyH0cd
免礦機挖比特幣礦軟體(需下載安裝,Google帳號登入即可):
https://cryptotabbrowser.com/en/22707142/
Pi加密貨幣(史丹佛大學):請點擊這個鏈接 https://minepi.com/derektu 下載,輸入邀請碼:derektu,即可獲得1顆Pi加密貨幣並加入礦場
Bee蜜蜂網鏈:請到 https://bee.games/download.html 下載,輸入邀請碼:derektu,即可獲得1顆Bee加密貨幣並加入礦場
杜仲教學部落格:
https://derekcctu.blogspot.com/
歡迎訂閱杜仲教學頻道: https://www.youtube.com/channel/UCElwt6s8Ea_V-gnu9sZZT5g?sub_confirmation=1 杜仲教學部落格: https://derekcctu.blogspot.com/
2021年6月19日 星期六
2020年11月28日 星期六
2020年11月27日 星期五
2020年11月20日 星期五
[Android]_ch7.1_shared preferences:存取偏好檔案的內容
教材訂閱頻道:杜仲教學YouTube
杜仲教學部落格:
[Android]_ch7.1_shared preferences:存取偏好檔案的內容
存取偏好設定檔案的說明如下:
呼叫Context的getSharedPreferences()取得SharedPreferences
getSharedPreferences settings=getSharedPreferences(String name, int mode)
呼叫SharedPreferences的edit()以取得SharedPreferences.Editor物件,方可編輯內容
settings.edit()
.putString(“key1", stringValue)
.putBoolean(“key2", booleanValue)
.putInt(“key3", intValue)
.commit();
呼叫SharedPreferences對應的getter方法取得對應資料
String fileName = settings.getString("key1", default_fileName);
呼叫SharedPreferences.Editor的remove()將指定資料移除
settings.edit()
.remove(key1)
.commit();
檔案儲存於 data/data/專案套件名稱/shared_prefs/prefSet.xml
package com.derek.ch21_sharepreference;
import android.R.integer;
import android.app.Activity;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Toast;
public class MainActivity extends Activity {
Button btn1,btn2,btn3;
RadioButton rb1,rb2;
EditText et1,et2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et1=(EditText)findViewById(R.id.editText1);
et2=(EditText)findViewById(R.id.editText2);
rb1=(RadioButton)findViewById(R.id.radioButton1);
rb2=(RadioButton)findViewById(R.id.radioButton2);
btn1=(Button)findViewById(R.id.button1);
btn2=(Button)findViewById(R.id.button2);
btn3=(Button)findViewById(R.id.button3);
btn1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String fileName=et1.getText().toString();
boolean isAuto=false;
if(rb1.isChecked())
isAuto=true;
else
isAuto=false;
int sec=Integer.parseInt(et2.getText().toString());
SharedPreferences sp=getSharedPreferences("Gjun2019", MODE_PRIVATE);
Editor editor=sp.edit();
editor.putString("1", fileName);
editor.putBoolean("2", isAuto);
editor.putInt("3", sec);
editor.commit();
Toast.makeText(MainActivity.this, "1.儲存成功...", Toast.LENGTH_SHORT).show();
}
});
btn2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
SharedPreferences sp=getSharedPreferences("Gjun2019", MODE_PRIVATE);
String fileName= sp.getString("1", "找不到檔案");
et1.setText(fileName);
boolean isAuto=sp.getBoolean("2", true);
if(isAuto)
rb1.setChecked(true);
else
rb2.setChecked(true);
int sec=sp.getInt("3", 120);
et2.setText(Integer.toString(sec));
Toast.makeText(MainActivity.this, "2.載入成功...", Toast.LENGTH_SHORT).show();
}
});
btn3.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
et1.setText("Gjun.txt");
rb2.setChecked(true);
et2.setText(Integer.toString(100));
Toast.makeText(MainActivity.this, "3.回復預設...", Toast.LENGTH_SHORT).show();
}
});
}
}
2020年11月14日 星期六
2020年11月13日 星期五
2020年11月7日 星期六
訂閱:
文章 (Atom)
Ether.fi Cash Card 一張所有人必備的加密貨幣信用卡 [Ether.fi Cash Card] : https://www.ether.fi/app/cash/sign-up?ref_code=d27f8523 ------國際交易所------ [Bitg...
-
22.Hamster Kombat Daily Combo倉鼠戰鬥_DailyCombo0620 ------國際交易所------ [Bitget 交易所]: https://partner.bitget.com/bg/DCA888 邀請碼:DCA888 [Bybit交...
-
[CATS coin每日任務(Ton區塊鏈游戲伏擊百倍幣)] https://t.me/catsgang_bot/join?startapp=FXvTt0OIdo7NJ4jxDutEV ------國際交易所------ [Bitget 交易所]: https://partn...