Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

Android Fragment Examples



Code look up at the Api Demos

android_fragments arguments attributes - three fragments on screen
android_fragments_arguments

android_fragments_alert_dialog
android_fragments_alert_dialog.png

android_fragments_context_menu
android_fragments_context_menu.png

android_fragments_custom_animation
android_fragments_custom_animation.png

android_fragments_dialog
android_fragments_dialog.png

android_fragments_dialog_or_activity
android_fragments_dialog_or_activity.png

fragment_hide_show
fragment_hide_show.png

fragment_layout
fragment_layout

fragments_list_array
fragments_list_array.png

fragment_menu
fragment_menu.png

android_fragments_get_result_from_fragment and tabs in two rows
android_fragments_get_result_from_fragment.png

android_fragments_recive_result
android_fragments_recive_result.png

android_fragments_stack
android_fragments_stack.png

fragment_tabs
fragment_tabs.png






397LW NO topic_id



Další témata ....(Topics)


95

How set text to TextView as HTM HTML format Android example | how-set-text-to-textview-as-htm-html-format-android-example


Html.fromHtml(), setText(), textView.setText(Html.fromHtml(String htmlFormat)), Android example.

TextView mIdTextOk = (TextView)findViewById(R.id.idTextOk);
int _nOk = 57;
// number 57 will bold style
mIdTextOk.setText(Html.fromHtml( "OK: "+"<b>"+_nOk+"</b>")); 
221

SparseArray instead HashMap Android example | sparsearray-instead-hashmap-android-example


Old code with HashMap

 Map<Integer, Bitmap> _bitmapCache = new HashMap<Integer, Bitmap>();
   private void fillBitmapCache() {
        _bitmapCache.put(R.drawable.icon, BitmapFactory.decodeResource(getResources(), R.drawable.icon));
        _bitmapCache.put(R.drawable.abstrakt, BitmapFactory.decodeResource(getResources(), R.drawable.abstrakt));
        _bitmapCache.put(R.drawable.wallpaper, BitmapFactory.decodeResource(getResources(), R.drawable.wallpaper));
        _bitmapCache.put(R.drawable.scissors, BitmapFactory.decodeResource(getResources(), 
    }

Bitmap bm = _bitmapCache.get(R.drawable.icon);

Lint warning:
Use new SparseArray(...) instead for better performance
Issue: Looks for opportunities to replace HashMaps with the more efficient SparseArray
Id: UseSparseArrays

New code with SparseArray

 SparseArray<Bitmap> _bitmapCache = new SparseArray<Bitmap>();
   private void fillBitmapCache() {
        _bitmapCache.put(R.drawable.icon, BitmapFactory.decodeResource(getResources(), R.drawable.icon));
        _bitmapCache.put(R.drawable.abstrakt, BitmapFactory.decodeResource(getResources(), R.drawable.abstrakt));
        _bitmapCache.put(R.drawable.wallpaper, BitmapFactory.decodeResource(getResources(), R.drawable.wallpaper));
        _bitmapCache.put(R.drawable.scissors, BitmapFactory.decodeResource(getResources(), 
    }

Bitmap bm = _bitmapCache.get(R.drawable.icon);


SparseArray methods:
//developer.android.com/reference/android/util/SparseArray.html
240

AdMob in Android 4 version | admob-in-android-4-version


AdMob in Android emulator not visible?
You have to using some from this libraries:
GoogleAdMobAdsSdk-4.3.1.jar
GoogleAdMobAdsSdk-6.0.1.jar
GoogleAdMobAdsSdk-6.2.1.jar

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="//schemas.android.com/apk/res/android"
    package="cz.okhelp.admob"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="13"
        android:targetSdkVersion="16"/>

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

    <application android:icon="@drawable/ic_launcher" android:label="@string/app_name">
       <meta-data 
        android:value="a14d932xxxxxxxx" 
        android:name="ADMOB_PUBLISHER_ID" />
        <activity android:name=".AdmobActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

<activity android:name="com.google.ads.AdActivity"
 android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>
</manifest>


onCreate in your Activity.java

		@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
     			AdViw adView = new AdView(this, AdSize.BANNER, "a14d932xxxxxxxxx");//MY_AD_UNIT_ID
    			LinearLayout layout = (LinearLayout)findViewById(R.id.idReklamaLayout);
				// Add the adView to it
    			layout.addView(adView);
				// Initiate a generic request to load it with an ad
				AdRequest adRequest = new AdRequest();
    			//adRequest.setTesting(true);
    			adRequest.setGender(AdRequest.Gender.MALE);
    			adView.loadAd(adRequest);
    }



main.xml (res/layout)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="//schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />
<LinearLayout xmlns:android="//schemas.android.com/apk/res/android"
android:id="@+id/idReklamaLayout"
android:orientation="vertical"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="3" />

</LinearLayout>
177

Statistics usability of mobile phones with Android – February 2012 | statistics-usability-of-mobile-phones-with-android-%e2%80%93-february-2012


Table of usability of mobile phones with Android – February 2012 - (application Sky Map)















1 Samsung Galaxy S2 6.3%
2 HTC Desire HD 3.5%
3 HTC Evo 4G 3.4%
4 Samsung Galaxy Ace 2.1%
5 Samsung Galaxy S (SCH-I500) 2.1%
6 Samsung Galaxy S (GT-I9000) 2.1%
7 HTC Incredible 2 2.0%
8 Motorola Droid X 1.9%
9 Motorola Droid RAZR 1.9%
10 HTC Sensation 4G 1.7%

43

No title bar Android application without titlebar style Theme NoTitleBar Android example | no-title-bar-android-application-without-titlebar-style-theme-notitlebar-android-example


Set in AndroidManifest.xml android:theme="@android:style/Theme.NoTitleBar" AndroidManifest.xml example source code.
AndroidManifest.xml


<manifest xmlns:android="//schemas.android.com/apk/res/android"
    package="com.myexample.without_titlebar">
    <application android:label="My app">
      <activity android:name="NoTitleBar"
        android:theme="@android:style/Theme.NoTitleBar"
        android:screenOrientation="portrait"
        android:configChanges="keyboardHidden|orientation">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>



Editace Jana Žákovská : 2017-02-01 12:36:57
Počet článků v kategorii: 397
Url:android-fragment-examples
Share
Share
Tweet