Create About Dialog Android Example
Wiktionary - SDK samples Android
about.xml
protected void showAbout() {
// Inflate the about message contents
View messageView = getLayoutInflater().inflate(R.layout.about, null, false);
// When linking text, force to always use default color. This works
// around a pressed color state bug.
TextView textView = (TextView) messageView.findViewById(R.id.about_credits);
int defaultColor = textView.getTextColors().getDefaultColor();
textView.setTextColor(defaultColor);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setIcon(R.drawable.app_icon);
builder.setTitle(R.string.app_name);
builder.setView(messageView);
builder.create();
builder.show();
}
about.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2009 The Android Open Source Project
//www.apache.org/licenses/LICENSE-2.0
-->
<LinearLayout xmlns:android="//schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dip">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="@string/app_descrip"
android:textColor="?android:attr/textColorPrimaryInverse" />
<TextView
android:id="@+id/about_credits"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="20dip"
android:textSize="16sp"
android:text="@string/app_credits"
android:autoLink="web"
android:textColor="?android:attr/textColorPrimaryInverse" />
</LinearLayout>
396LW NO topic_id
AD
Další témata ....(Topics)
Click to Android version combobox - drop down menu and select your version, which just using (have instaled). For example: You updated ADT by SDK manager, but forget to update Android version. You can use lower version from drop down menu, which using your project, or do update of Android by SDK manager.
First: AdView is in XML file
Second: Using AdView in Fragment with LinearLayout
Resolve error in ADT Graphical layout editor:
The following classes could not be instantiated:
- com.google.android.gms.ads.AdView
More about:
https://developers.google.com/mobile-ads-sdk/docs/admob/android/play-migration?hl=it
<com.google.android.gms.ads.AdView
xmlns:ads="//schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adUnitId="MY_AD_UNIT_ID"
ads:adSize="BANNER"/>
// onResume
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("TEST_DEVICE_ID")
.build();
adView.loadAd(adRequest);
Second: Using AdView in Fragment with LinearLayout
Resolve error in ADT Graphical layout editor:
The following classes could not be instantiated:
- com.google.android.gms.ads.AdView
// layout in xml file
<LinearLayout
android:id="@+id/layout"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
// java class with fragment in Fragment class or in Activity class
private static AdView adView;
@Override
public void onResume(){
super.onResume();
try {
// in xml is empty layout
adView = new AdView(getActivity());
adView.setAdUnitId("ca-app-pub-626/638103xxxxxxx");
adView.setAdSize(AdSize.BANNER);
LinearLayout layout = (LinearLayout)getView() .findViewById(R.id.layout);
layout.addView(adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
More about:
https://developers.google.com/mobile-ads-sdk/docs/admob/android/play-migration?hl=it
FrameLayou, fragment have to unique id android:id="@+id/your_id_unique"
<FrameLayout xmlns:android="//schemas.android.com/apk/res/android"
xmlns:tools="//schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
android:id="@+id/your_id_unique"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="cz.okhelp.notepad.AddNoteFragment"
tools:layout="@layout/add_note" />
</FrameLayout>
If Android emulator freezes at startup, try create new virtual device with smaller memory and cpu usage, or select older version of Android, or buy new pc with higher performance.
- open AVD MANAGER
- press Create Virtual Device
- select Device with small memory usage (e.g. 480x800 of resolution) - Next
- check - Show downloadable ....
- Download - lower version of system Android, select, press - Next
- check data, Show Advanced Settings, check Use host... and press Finish
Editace: 2013-01-08 13:44:25
Počet článků v kategorii: 396
Url:create-about-dialog-android-example