最近在做一個睇星坐APP, 一開始有一個 edittext, 但一當 load activity 時就該edittext 就立即on focus 彈出 virtual keyboard
google 一下, 只要在Activity::OnCreate 中加入以下 code 即可 !!!
// hidden keyboard
this.getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Wednesday, March 28, 2012
Tuesday, February 07, 2012
Set up DfpAdView/AdView of admob
教學有很多, 但大多十分多肺話, 所以我的十分精簡:
1) Reg On Admob site to get the Publisher ID - a14exxxxxxxxxx
2) Mainfest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<activity
android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
3) Add a LinearLayout called ad_layout to the Activity "XML" file that u want to show the ad.
4a) Add the code to the correspondence Activity "JAVA Code" file
------- Field -------
private DfpAdView mAdView;
I----- onCreate ------
final LinearLayout adRow = (LinearLayout) findViewById(R.id.ad_layout);
mAdView = new DfpAdView(this, AdSize.SMART_BANNER, "a14exxxxxxxxxx");
adRow.addView(mAdView);
mAdView.loadAd(new AdRequest());
4b) Change DfpAdView to AdView, if u want AdView
5) Override onDestory
@Override
protected void onDestroy() {
if (mAdView != null) {
mAdView.removeAllViews();
mAdView.destroy();
}
super.onDestroy();
}
6) Run Test !!!!
PS: Add DfpInterstitialAd Later
1) Reg On Admob site to get the Publisher ID - a14exxxxxxxxxx
2) Mainfest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<activity
android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
3) Add a LinearLayout called ad_layout to the Activity "XML" file that u want to show the ad.
4a) Add the code to the correspondence Activity "JAVA Code" file
------- Field -------
private DfpAdView mAdView;
I----- onCreate ------
final LinearLayout adRow = (LinearLayout) findViewById(R.id.ad_layout);
mAdView = new DfpAdView(this, AdSize.SMART_BANNER, "a14exxxxxxxxxx");
adRow.addView(mAdView);
mAdView.loadAd(new AdRequest());
4b) Change DfpAdView to AdView, if u want AdView
5) Override onDestory
@Override
protected void onDestroy() {
if (mAdView != null) {
mAdView.removeAllViews();
mAdView.destroy();
}
super.onDestroy();
}
6) Run Test !!!!
PS: Add DfpInterstitialAd Later
Subscribe to:
Posts (Atom)