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.

Iterate HashMap getKey getValue Java Example


AD MOB


 HashMap<String,Locale> _mapOfLocale = new HashMap<String,Locale>();
    _mapOfLocale.put("French",Locale.	FRENCH	);	
    _mapOfLocale.put("German",Locale.	GERMAN	);	
    _mapOfLocale.put("Italian",Locale.	ITALIAN	);	

    for (Entry<String, Locale> entry : _mapOfLocale.entrySet()) {

       System.out.println(entry.getKey());
       System.out.println(entry.getValue());

      }




397LW NO topic_id




AD

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


218

How to save the state of Activity - Android | how-to-save-the-state-of-activity-android


onSaveInstanceState, onRestoreInstanceState , save preferences

int mCurrentPhotoIndex = 0;
   @Override
    protected void onSaveInstanceState(Bundle outState) {
        outState.putInt("photo_index", mCurrentPhotoIndex);
        super.onSaveInstanceState(outState);
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        mCurrentPhotoIndex = savedInstanceState.getInt("photo_index");
        super.onRestoreInstanceState(savedInstanceState);
    }

// or save preferences for new start of Activity in onStop
//onCreate or onResume or onStart etc.
public void loadPreferences() {
		SharedPreferences settings = getSharedPreferences(F.PREFERENCES_NAME, 0);
		mCurrentPhotoIndex = settings.getInt("mCurrentPhotoIndex",mCurrentPhotoIndex);
	// String_sOtazka = settings.getString("_sOtazka", _sOtazka);


}
// onStop
public void savePreferences() {
		SharedPreferences settings = getSharedPreferences(PREFERENCES_NAME, 0);
		SharedPreferences.Editor editor = settings.edit();
		editor.putInt("mCurrentPhotoIndex", mCurrentPhotoIndex);
                // String, boolean, float ...
		// editor.putString("mButton1", mButton1.getText().toString());

		editor.commit();

}

260

SeekBar listener Android Example Source | seekbar-listener-android-example-source


SeekBar setOnSeekBarChangeListener Example. Change TextView font size by SeekBar Example.

        TextView mTextView01 = (TextView)findViewById(R.id.textView01);

        SeekBar  mSeekBarTexSize = (SeekBar)findViewById(R.id.seekBarTextSize);
        mSeekBarTexSize.setMax(100);
        mSeekBarTexSize.setProgress(25);

        mSeekBarTexSize.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            public void onProgressChanged(SeekBar seekBar, int progress,
                    boolean fromUser) {
            	mTextView01.setTextSize((float)progress);
            }

            public void onStartTrackingTouch(SeekBar seekBar) {}
            public void onStopTrackingTouch(SeekBar seekBar) {}
        });


184

Transparent Background Android example | transparent-background-android-example


android:background="@android:color/transparent"

<LinearLayout
    android:baselineAligned="false"
    android:background="@android:color/transparent"
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
   >
<LinearLayout>
////////////////////////////
LinearLayout  mLinearLayout1 = (LinearLayout)findViewById(R.id.linearLayout1);
mLinearLayout1.setBackgroundColor(Color.TRANSPARENT);

389

Expected resource of type raw drawable | expected-resource-of-type-raw-drawable


Try insert + before R.drawable.xxxx

// error
InputStream is = context.getResources().openRawResource(R.drawable.app_sample_code);

// ok
InputStream is = context.getResources().openRawResource(+R.drawable.app_sample_code);

324

Set Default Start Up Activity Class Java AndroidManifest xml | set-default-start-up-activity-class-java-androidmanifest-xml


Insert into your default start up activity tag inten-filter tag with action MAIN and category LAUNCHER

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>


AndroidManifest.xml

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>


Editace: 2013-12-09 10:59:38
Počet článků v kategorii: 397
Url:iterate-hashmap-getkey-getvalue-java-example

AD
11 Share
Share
Tweet