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 Java functions samples



Java Android functions and method examples of using.

.abs

.accept

.acquire

.add

.addAccountExplicitly

.addAction

.addAnimation

.addBitmap

.addCallback

.addCategory

.addCircle

.addDataScheme

.addEarcon

.addEmail

.addFirst

.addFlags

.addGesture

.addHeader

.addIntentOptions

.addName

.addOnGestureListener

.addPhone

.addPhotos

.addPreference

.addRule

.addShape

.addTab

.addTextChangedListener

.addURI

.addVertex

.addView

.adjustMetaAfterKeypress

.allocate

.allocateDirect

.alpha

.animate

.animateTransform

.answerCall

.append

.appendEncodedPath

.appendId

.appendWhere

.applyBatch

.arcTo

.argb

.arraycopy

.asFloatBuffer

.asIntBuffer

.asInterface

.asShortBuffer

.assignContactUri

.attachInterface

.attemptAuth

.authenticate

.available

.BackupAgent#onBackup

.BackupAgent#onRestore

.basicTypes

.beginAdding

.beginBatchEdit

.beginBroadcast

.beginDrawing

.blockingGetAuthToken

.blue

.build

.Builder

.buildUpon

.callActivityOnPause

.callActivityOnResume

.Callback#onKeyDown

.cancel

.cancelDiscovery

.charAt

.check

.checkArgument

.checkNotNull

.clear

.clearCheck

.clearHistory

.clearMetaKeyStates

.clearPhotos

.clearQueue

.clipPath

.clipRect

.close

.closing

.colorChanged

.commit

.commitText

.compare

.compareTo

.compile

.compress

.compressTexture

.computeBounds

.computePhysics

.concat

.connect

.ContactListAdapter

.contains

.copyPixelsFromBuffer

.copyStringToBuffer

.cos

.create

.createBitmap

.createBufferObjects

.createFromAsset

.createFromPdu

.createFromResource

.createFromStream

.createNewContact

.createRfcommSocketToServiceRecord

.createScaledBitmap

.Creator

.cubicTo

.currentAnimationTimeMillis

.currentTimeMillis

.dataChanged

.decodeByteArray

.decodeResource

.decodeStream

.delete

.deleteTitlePref

.dismiss

.dispatchDraw

.dispatchKeyEvent

.divideMessage

.doKeyDown

.doKeyUp

.doStart

.draw

.drawArc

.drawBitmap

.drawBitmapMesh

.drawCircle

.drawColor

.drawLine

.drawLines

.drawOval

.drawPaint

.drawPath

.drawPicture

.drawPoints

.drawPosText

.drawRect

.drawText

.drawTextOnPath

.drawVertices

.duration

.edit

.elapsedRealtime

.elementAt

.encode

.endAdding

.endAnimation

.endBatchEdit

.endCall

.endDrawing

.endRecording

.enforceInterface

.equals

.eraseColor

.execSQL

.execute

.exists

.extractAlpha

.fade

.fetchFriendStatuses

.fetchFriendUpdates

.filter

.findItem

.findNextFocus

.findPointerIndex

.findViewById

.finish

.finishBroadcast

.finishComposingText

.format

.forName

.from

.fromContext

.fromFile

.fromHtml

.fromInt

.fromString

.frustumM

.generate

.get

.getAbsolutePath

.getAction

.getActionMasked

.getActivity

.getActivityInfo

.getAdapter

.getArray

.getAttributeValue

.getBandLevelRange

.getBinder

.getBondedDevices

.getBoolean

.getBooleanExtra

.getBounds

.getBroadcast

.getBroadcastItem

.getBundle

.getBundleExtra

.getBytes

.getCameraInfo

.getCheckedRadioButtonId

.getChildCount

.getClassName

.getColor

.getColumnIndex

.getColumnIndexOrThrow

.getComponent

.getContent

.getContentDescription

.getContentResolver

.getContext

.getCount

.getCurrentItemIndex

.getCurrentModelView

.getCurrentPlayer

.getCurrentProjection

.getData

.getDataSize

.getDeadChar

.getDefault

.getDefaultAdapter

.getDefaultDisplay

.getDefaultSensor

.getDefaultSharedPreferences

.getDeviceConfigurationInfo

.getDimensionPixelOffset

.getDimensionPixelSize

.getDouble

.getDrawable

.getEmail

.getEntity

.getExternalMediaDir

.getExternalStoragePublicDirectory

.getExternalStorageState

.getExtras

.getFirstName

.getFirstVisiblePosition

.getFontMetrics

.getGesture

.getGestureEntries

.getHeight

.getHistoricalPressure

.getHistoricalTouchMajor

.getHistoricalX

.getHistoricalY

.getHistorySize

.getHolder

.getIBinder

.getIcon

.getIndexCount

.getInputStream

.getInstance

.getInstrumentation

.getInt

.getIntArray

.getInteger

.getIntExtra

.getIntrinsicHeight

.getIntrinsicWidth

.getItem

.getItemAtPosition

.getItemCount

.getJetPlayer

.getJSONArray

.getJSONObject

.getKey

.getKeyboard

.getLanguage

.getLastPathSegment

.getLayoutParams

.getLocationOnScreen

.getLong

.getLooper

.getMatrix

.getMaxCaptureRate

.getMeasuredHeight

.getMeasuredWidth

.getMenuInfo

.getMode

.getName

.getNumberOfBands

.getNumberOfCameras

.getNumStars

.getOnlyElement

.getOpacity

.getOriginatingAddress

.getOutputStream

.getPackageInfo

.getPackageManager

.getPackageName

.getPackedPositionChild

.getPackedPositionGroup

.getPackedPositionType

.getPadding

.getPaddingRight

.getPageContent

.getPaint

.getParameters

.getParams

.getParcelable

.getParcelableArrayExtra

.getParcelableExtra

.getParticleCount

.getPassword

.getPathSegments

.getPayload

.getPeerProfile

.getPid

.getPixels

.getPointerCount

.getPointerId

.getPosX

.getPosY

.getReadableDatabase

.getRecentTasks

.getRecords

.getRemoteDevice

.getResourceId

.getResources

.getRight

.getRingerMode

.getRootDirectory

.getSavedText

.getScaledHeight

.getScaledWidth

.getSelectedItemPosition

.getSelection

.getService

.getSharedPreferences

.getSize

.getSpinnerPosition

.getSpinnerSelection

.getStatusLine

.getStepSize

.getStore

.getStreamMaxVolume

.getStreamVolume

.getString

.getStringArray

.getStringArrayListExtra

.getStringExtra

.getStrokePaint

.getStrokeWidth

.getSurfaceFrame

.getSyncAdapterBinder

.getSystem

.getText

.getTextBounds

.getTextSize

.getTextWidths

.getThread

.getTnf

.getTransformation

.getType

.getUnicodeChar

.getUserId

.getValue

.getView

.getWidth

.getWord

.getWordMatches

.getWritableDatabase

.getX

.getXPrecision

.getY

.getYPrecision

.glActiveTexture

.glAlphaFunc

.glAlphaFuncx

.glAttachShader

.glBindBuffer

.glBindFramebufferOES

.glBindRenderbufferOES

.glBindTexture

.glBlendFunc

.glBufferData

.glCheckFramebufferStatusOES

.glClear

.glClearColor

.glClearColorx

.glClearDepthf

.glClearDepthx

.glClearStencil

.glClientActiveTexture

.glClipPlanef

.glClipPlanex

.glColor4f

.glColor4x

.glColorMask

.glColorPointer

.glCompileShader

.glCompressedTexImage2D

.glCompressedTexSubImage2D

.glCopyTexImage2D

.glCopyTexSubImage2D

.glCreateProgram

.glCreateShader

.glCullFace

.glCurrentPaletteMatrixOES

.glDeleteProgram

.glDeleteShader

.glDeleteTextures

.glDepthFunc

.glDepthMask

.glDepthRangef

.glDepthRangex

.glDisable

.glDisableClientState

.glDrawArrays

.glDrawElements

.glDrawTexfOES

.glDrawTexfvOES

.glDrawTexiOES

.glDrawTexivOES

.glDrawTexsOES

.glDrawTexsvOES

.glDrawTexxOES

.glDrawTexxvOES

.glEnable

.glEnableClientState

.glEnableVertexAttribArray

.glFinish

.glFlush

.glFogf

.glFogfv

.glFogx

.glFogxv

.glFramebufferRenderbufferOES

.glFramebufferTexture2DOES

.glFrontFace

.glFrustumf

.glFrustumx

.glGenBuffers

.glGenFramebuffersOES

.glGenRenderbuffersOES

.glGenTextures

.glGetAttribLocation

.glGetError

.glGetIntegerv

.glGetProgramiv

.glGetShaderiv

.glGetString

.glGetUniformLocation

.glHint

.glLightf

.glLightfv

.glLightModelf

.glLightModelfv

.glLightModelx

.glLightModelxv

.glLightx

.glLightxv

.glLineWidth

.glLineWidthx

.glLinkProgram

.glLoadIdentity

.glLoadMatrixf

.glLoadMatrixx

.glLoadPaletteFromModelViewMatrixOES

.glLogicOp

.glMaterialf

.glMaterialfv

.glMaterialx

.glMaterialxv

.glMatrixIndexPointerOES

.glMatrixMode

.glMultiTexCoord4f

.glMultiTexCoord4x

.glMultMatrixf

.glMultMatrixx

.glNormal3f

.glNormal3x

.glNormalPointer

.glOrthof

.glOrthox

.glPixelStorei

.glPointSize

.glPointSizex

.glPolygonOffset

.glPolygonOffsetx

.glPopMatrix

.glPushMatrix

.glQueryMatrixxOES

.glReadPixels

.glRenderbufferStorageOES

.glRotatef

.glRotatex

.glSampleCoverage

.glSampleCoveragex

.glScalef

.glScalex

.glScissor

.glShadeModel

.glShaderSource

.glStencilFunc

.glStencilMask

.glStencilOp

.glTexCoordPointer

.glTexEnvf

.glTexEnvfv

.glTexEnvx

.glTexEnvxv

.glTexGeni

.glTexImage2D

.glTexParameterf

.glTexParameteri

.glTexParameteriv

.glTexParameterx

.glTexSubImage2D

.glTranslatef

.glTranslatex

.gluLookAt

.glUniformMatrix4fv

.glUseProgram

.glVertexAttribPointer

.glVertexPointer

.glViewport

.glWeightPointerOES

.green

.group

.handleKeyDown

.handleKeyUp

.handleMessage

.has

.hasCategory

.hasEnded

.hashCode

.hasStarted

.height

.includeAllPackagesUnderHere

.incrementProgressBy

.incrementSecondaryProgressBy

.indexOf

.inflate

.init

.initialize

.insert

.insertStatuses

.interrupt

.invalidate

.invalidateAuthToken

.invert

.invoke

.isAdminActive

.isChecked

.isColumnCollapsed

.isColumnShrinkable

.isColumnStretchable

.isInProgress

.isInside

.iterator

.join

.kill

.killProcess

.lastIndexOf

.layout

.LayoutParams

.length

.lineTo

.ListAdapter#getCount

.ListAdapter#getItem

.ListAdapter#getItemId

.ListAdapter#getView

.Listener

.listenUsingRfcommWithServiceRecord

.load

.loadAllTitlePrefs

.loadAnimation

.loadData

.loadIcon

.loadJetFile

.loadLabel

.loadLayoutAnimation

.loadTexture

.loadTitlePref

.lockCanvas

.lockNow

.makeAudioCall

.makeMeasureSpec

.makeText

.mapPoints

.matcher

.max

.measure

.measureText

.min

.mkdirs

.MorseCodeConverterTest#testCharacterS

.moveTo

.moveToFirst

.multiply

.multiplyMM

.multiplyMV

.mutate

.myPid

.nanoTime

.newDelete

.newInsert

.newInstance

.newPullParser

.newUpdate

.newView

.newWakeLock

.next

.nextBoolean

.nextInt

.notify

.notifyDataSetChanged

.obtain

.obtainMessage

.obtainStyledAttributes

.offsetTo

.onActivityResult

.onAttachedToWindow

.onBackup

.onBindView

.onCellSelected

.OnCheckedChangeListener

.OnClickListener

.onContextItemSelected

.onCreate

.onCreateContextMenu

.onCreateDialog

.onCreateOptionsMenu

.OnDateSetListener

.onDestroy

.onDetachedFromWindow

.onDrag

.onDraw

.OnEditorActionListener

.onFinishInput

.onFocusChanged

.OnItemSelectedListener#onItemSelected

.onKeyDown

.onKeyUp

.onLongPress

.onMeasure

.OnMultiChoiceClickListener

.onNewIntent

.onOptionsItemSelected

.onPause

.onPostExecute

.onPreExecute

.onPrepareDialog

.onPrepareOptionsMenu

.onProgressUpdate

.onRestore

.onRestoreInstanceState

.onResume

.onSaveInstanceState

.onScale

.OnScanCompletedListener

.onSizeChanged

.onStart

.onStartInput

.onStartInputView

.onStop

.onSurfaceChanged

.onSurfaceCreated

.onSurfaceDestroyed

.OnTimeSetListener

.onTouchEvent

.onTransact

.onUpdateSelection

.onWindowFocusChanged

.open

.openRawResource

.Options

.order

.orthoM

.parse

.parseFloat

.parseInt

.parseLong

.pattern

.pause

.performClick

.performOnBackgroundThread

.pickSuggestionManually

.play

.playEarcon

.poll

.position

.post

.postConcat

.postDelayed

.postTranslate

.prepare

.prepareUserAgent

.preTranslate

.printStackTrace

.project

.Proxy

.put

.putBoolean

.putBundle

.putDouble

.putExtra

.putIndices

.putInt

.putIntArray

.putLong

.putParcelable

.putString

.putStringArrayList

.quadTo

.query

.queryIntentActivities

.queueJetSegment

.quit

.random

.read

.readBoolean

.readDouble

.readEntityData

.readException

.readFloat

.readInt

.readLong

.readString

.recycle

.red

.registerCallback

.registerListener

.registerOnSharedPreferenceChangeListener

.registerReceiver

.release

.remove

.removeActiveAdmin

.removeAllViews

.removeCallbacks

.removeElementAt

.removeGesture

.removeItem

.removeMessages

.removeView

.requery

.requestFocus

.reset

.resetPassword

.resolveActivity

.resolveCollisionWithBounds

.restore

.restoreState

.restoreToCount

.results

.rewind

.rotate

.rotateY

.round

.run

.runOnUiThread

.save

.saveLayer

.saveLayerAlpha

.saveRecentQuery

.saveState

.scale

.scaleM

.scanFile

.schedule

.send

.sendEmptyMessage

.sendEmptyMessageDelayed

.sendKeys

.sendMessage

.sendMessageDelayed

.sendTextMessage

.sendToTarget

.set

.setAction

.setActivity

.setActivityToSpoof

.setAdapter

.setAdjustViewBounds

.setAlpha

.setAlphabeticShortcut

.setAngle

.setAnimationListener

.setAntiAlias

.setARGB

.setAudioStreamType

.setBackgroundColor

.setBackgroundDrawable

.setBackgroundResource

.setBandLevel

.setBase

.setBitmap

.setBounds

.setButton

.SetButtonView

.setCamera

.setCancelable

.setCaptureSize

.setCell

.setCellListener

.setChecked

.setChoiceMode

.setClass

.setClassName

.setClickable

.setColor

.setColorFilter

.setColumnCollapsed

.setColumnShrinkable

.setColumnStretchable

.setComponent

.setComponentEnabledSetting

.setCompoundDrawables

.setCompoundDrawablesWithIntrinsicBounds

.setConnectionTimeout

.setContent

.setContentView

.setCornerRadii

.setCurrentHour

.setCurrentMinute

.setCurrentPlayer

.setCurrentView

.setData

.setDataCaptureListener

.setDataSource

.setDefaultValues

.setDialogTitle

.setDialogue

.setDifficulty

.setDisplay

.setDither

.setDrawFilter

.setDrawingCacheEnabled

.setDropDownViewResource

.setDuration

.setEGLConfigChooser

.setEGLContextClientVersion

.setEmpty

.setEnabled

.setEntity

.setEntries

.setEntryValues

.setError

.setEventListener

.setExpanded

.setFaceColor

.setFactory

.setFakeBoldText

.setFavorites

.setFillAfter

.setFillType

.setFilterBitmap

.setFinished

.setFixedSize

.setFlags

.setFocusable

.setFocusableInTouchMode

.setFormat

.setGameState

.setGesture

.setGLWrapper

.setGradientRadius

.setGradientType

.setGravity

.setGroupVisible

.setHeader

.setHeaderTitle

.setHeight

.setHorizontalGravity

.setIcon

.setId

.setIdentity

.setIdentityM

.setImageBitmap

.setImageDrawable

.setImageResource

.setImageViewResource

.setImeOptions

.setInAnimation

.setIndeterminate

.setIndicator

.setInput

.setIntent

.setInterpolator

.setIntrinsicHeight

.setIntrinsicWidth

.setItems

.setItemsCanFocus

.setKey

.setKeyboard

.setLang

.setLanguage

.setLatestEventInfo

.setLayoutAnimation

.setLayoutAnimationListener

.setLayoutParams

.setLayoutResource

.setLength

.setLocalMatrix

.setLookAtM

.setMargins

.setMaskFilter

.setMax

.setMaximumFailedPasswordsForWipe

.setMaximumTimeToLock

.setMediaController

.setMessage

.setMinimumWidth

.setMode

.setMovementMethod

.setMultiChoiceItems

.setMuteArray

.setMuteFlag

.setNegativeButton

.setNeutralButton

.setNotificationUri

.setNotifyOnChange

.setNumStars

.setOnBufferingUpdateListener

.setOnCancelListener

.setOnCheckedChangeListener

.setOnClickListener

.setOnClickPendingIntent

.setOnCompletionListener

.setOnEditorActionListener

.setOnItemClickListener

.setOnItemSelectedListener

.setOnKeyboardActionListener

.setOnKeyListener

.setOnPreparedListener

.setOnSeekBarChangeListener

.setOnTimeChangedListener

.setOnTouchListener

.setOnVideoSizeChangedListener

.setOrientation

.setOutAnimation

.setPadding

.setParameters

.setPassword

.setPasswordMinimumLength

.setPasswordQuality

.setPathEffect

.setPersistentDrawingCache

.setPixels

.setPolyToPoly

.setPositiveButton

.setPreviewDisplay

.setPreviewSize

.setProgress

.setProgressStyle

.setProjectionMap

.setPrompt

.setRating

.setRecents

.setRectToRect

.setRegistrationListener

.setRenderer

.setRepeatCount

.setRepeating

.setRepeatMode

.setRGB2YUV

.setRotate

.setRotateM

.setRunning

.setScale

.setScaleType

.setScreenHeight

.setScreenWidth

.setSelection

.setService

.setShader

.setShape

.setShifted

.setSingleChoiceItems

.setSingleLine

.setSoTimeout

.setSpan

.setSpeakerMode

.setSpinnerPosition

.setSpinnerSelection

.setStartOffset

.setState

.setStepSize

.setStrokeCap

.setStrokeJoin

.setStrokeWidth

.setStyle

.setSuggestions

.setSummary

.setSurfaceSize

.setSyncAutomatically

.setTables

.setTag

.setText

.setTextAlign

.setTextColor

.setTextKeepState

.setTextSize

.SetTextView

.setTextViewText

.setTime

.setTimeInMillis

.setTimeout

.setTimerView

.setTimeZone

.setTitle

.setTokenizer

.setToNow

.setTranslate

.setType

.setTypeface

.setUp

.setValue

.setVerticalGravity

.setVideoPath

.setVideoURI

.setView

.setVisibility

.setWinner

.setXfermode

.setYUV2RGB

.show

.shutdown

.SimpleOnScaleGestureListener

.sin

.size

.skipEntityData

.sleep

.sort

.speak

.split

.sqrt

.start

.startActivity

.startAnimation

.startAudio

.startDiscovery

.startFlipping

.startHierarchyTracing

.startLayoutAnimation

.startNow

.startPreview

.startService

.startSimulation

.startsWith

.Status

.Status>

.step

.stop

.stopBlink

.stopHierarchyTracing

.stopPreview

.stopSelf

.stopSimulation

.Stub

.subSequence

.substring

.switchCamera

.syncContacts

.synchronizedMap

.TabSpec#setContent

.TabSpec#setIndicator

.takeAudioCall

.tearDown

.texImage2D

.toBitmap

.toByteArray

.toggle

.toggleMute

.toHexString

.toLowerCase

.toString

.toUpperCase

.transact

.transformVertex

.translate

.translateM

.triggerClip

.unlockCanvasAndPost

.unpause

.unregisterCallback

.unregisterListener

.unregisterReceiver

.update

.updateAppWidget

.updateEmail

.updateExistingContact

.updateName

.updatePhone

.updateStatus

.updateVisualizer

.uptimeMillis

.valueChanged

.valueOf

.vibrate

.wait

.width

.wipeData

.withAppendedId

.withAppendedPath

.withValue

.withValueBackReference

.withValues

.write

.writeBoolean

.writeDouble

.writeEntityData

.writeEntityHeader

.writeFloat

.writeInt

.writeInterfaceToken

.writeLong

.writeNoException

.writeString

.writeStrongBinder

.writeTexture

.writeToParcel

.writeToStream


397LW NO topic_id



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


258

Save Restore Array List Android Example | save-restore-array-list-android-example



        int[] mArrayOfInt;
        String[] mArrayOfString;
        List<String> mList;
        public void saveState(Bundle map)
        {
                map.putIntArray("mArrayOfInt", mArrayOfInt);
                map.putStringArray("mArrayOfString", mArrayOfString);
                map.putStringArrayList("mList", mList);
        }

        public void restoreState(Bundle map)
        {
                mArrayOfInt= map.getIntArray("mArrayOfInt");
                mArrayOfString = map.getStringArray("mArrayOfString");
                mList = map.getStringArrayList("mList");

        }

91

Class File Editor - Source not found - Change Attached Source - Eclipse | class-file-editor-source-not-found-change-attached-source-eclipse


The source attachment does not contain the source for the file TextWatcher.class.
You can change the source attachment by clicking Change Attached Source below:

You have to add JDK src.zip path to dialog as on image below.
[caption id="attachment_1091" align="alignleft" width="282" caption="class file editor source not found Eclipse warning"][/caption]



Or go to Project > Properties > Java Build Path > Libraries
Expand JRE System Library. Expand rt.jar.
Select Source attachment and double click or Edit.
Type path the source code file (External File…) and press OK.

[caption id="attachment_1094" align="alignleft" width="300" caption="Java project build path"][/caption]



Or type path in Java JRE definition



[caption id="attachment_1105" align="alignleft" width="300" caption="Java JRE deifiniton path in Eclipse"][/caption]

How open String.class or others keywords definition with Eclipse.



Now if mouse move about keywords String or F3 on keywords and press button in yellow field will opened String.class
Java Eclipse intellisense




Java-string-class-image
378

4. Fragments Tutorial ArticleFragment.java – Czech language | 4-fragments-tutorial-articlefragment-java-czech-language


Dil 4. ArticleFragment.java
V 1. dílu jsme se něco dozvěděli od XML souborech a typu procesoru pro správný běh Android Studia a emulátoru různých typů zařizení s Androidem.
V 2. dílu jsme rozebrali MainActivity.java
V 3. dílu jsme se zabývali HeadlinesFragment.java


V tomto dílu se podíváme na ArticleFragment.java soubor.
Používáme příklad i zip porojekt z https://developer.android.com/training/basics/fragments/creating.html Pozorně si jej nastudujte.




package com.example.android.fragments;
// knihovna pro nižší verze Androidu
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
// extends Fragment - už nebude obsahovat funkci onCreate jako v Activity
// ale onCreateView
public class ArticleFragment extends Fragment {
    // důležité pro uložení argumentu - argumentů (hodnot)
	// pro obnovení předchozího stavu obsahu obrazovky
	// např. při rotaci zařízení atd.
	final static String ARG_POSITION = "position";
    int mCurrentPosition = -1;

TextView article; // uložen do globální proměnné, v originale
// odchycen v updateArticleView() ale tam vracel NULL

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
        Bundle savedInstanceState) {

		// Když je activity znovu vytvořena (např. při rotaci zařízení),
		// obnoví, v našem případě, text článku, jehož pozice 
		// byla uložena pomocí
        // public void onSaveInstanceState(Bundle outState) viz níže
		// důležité zejména pro dual-panel (dva panely vedle sebe)
        if (savedInstanceState != null) {
            mCurrentPosition = savedInstanceState.getInt(ARG_POSITION);
        }

// umístíme, aktivujeme příslušný layout
// zde je zajímavé, že layout můžete měnit.
// Např. při kliknutí na pložku 1 v HeadlinesFragment
// zde můžete ochytit pozici a dle toho zvolit 
// příslušný layout, který chcete zobrazit ve fragmentu 
// ALE pak si musíte pohlídat ID prvků, které bude ten JINÝ
// layout obsahovat

// Oproti originalu odchytíme TextView již zde, v originalu to vyhazovalo chybu 
 View rootView = inflater.inflate(R.layout.vnitrek, container, false);
        article = (TextView) rootView.findViewById(R.id.article);		
        return rootView;
    }

    @Override
    public void onStart() {
        super.onStart();
// Při startu fragmentu, zkontrolujte, zda existují nějaké argumenty 
// předané do fragmentu.
// OnStart() je právě to správné místo, kde to udělat, 
// protože layout s jednotlivými elementy byl již         
// naloděn - aktivován, a můžeme bezpečně použít metody,         
// které potřebují, aby jednotlivá ID elementů layoutu byla již          
// aktivní, použitelná	a nevracela NULL, což by mělo za následek
// pád aplikace	
		
        Bundle args = getArguments();
        if (args != null) {
			// vypsaní obsahu článku pomocí předaného argumentu (pozice) z HeadlinesFragment.java
            updateArticleView(args.getInt(ARG_POSITION));
        } else if (mCurrentPosition != -1) {
			// vypsání článku dle pozice uložené např. při rotaci zařízení
			// mCurrentPosition je definována (odchycena) v onCreateView
            updateArticleView(mCurrentPosition);
        }
    }
/** 
funkce která vypíše obsah článku do TextView. 
Jako parametr int position je pozice položky, 
na kterou bylo kliknuto v ListView v HeadlinesFragment.java
*/
    public void updateArticleView(int position) {
		// na rozdíl od Activity se ve Fragment používá k 
		// získání id ne jen findViewById() 
		// ALE getActivity().findViewById() 
//Tento kod vracel article == NULL , PROTO bylo nutno odchytit TextView
// v onCreateView()
        //TextView article = (TextView) getActivity().findViewById(R.id.article);
        
// vložení textu článku do TextView z Ipsum.java
		// je to pole stringů, kde position je pozice stringu v poli
		// static String[] Articles = {"","",""};
      if (article != null)
                article.setText(Ipsum.Articles[position]);
		
        mCurrentPosition = position;
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);

		// Uložení pozice článku - elementu, či jiných argumentů důležitých
		// pro obnovení stavu v onCreateView() např. při rotaci zařízení
        outState.putInt(ARG_POSITION, mCurrentPosition);
// TIP: zde můžeme vždy při rotaci zařízení podstrčit náhodnou pozici
// článku pomocí
// randomNum = minimum + (int)(Math.random() * maximum);
// a vytvořit tak zábavnou hru, například pro náhodné
// vypsání přísloví, či nějakého fyzikálního zákona atd.
// Stačí pak aby uživatel jen pootočil zařízení od 90° a zpět,
// k vypsání nové položky
    }
}
233

Date getDate is deprecated Java Android | date-getdate-is-deprecated-java-android


Date getDate is deprecated Java Android example code:


long dayInMili = 100000000;

GregorianCalendar calToDay = new GregorianCalendar();
int nD = calToDay.get((Calendar.MILLISECOND)); // +dayInMili;
System.out.println(nD);

long lTime = calToDay.getTimeInMillis();
System.out.println(lTime);

Date dtA = new Date(lTime); // today
///@SuppressWarnings("deprecation")
int nD1 = dtA.getDate(); // DEPRECATED Day Of Month 1 - 31
System.out.println(nD1+" nD1");

GregorianCalendar cal = new GregorianCalendar();
int nD2 = calToDay.get(Calendar.DATE); // Day Of Month
System.out.println(nD2+" nD2");

cal.setTimeInMillis(lTime+dayInMili);// setTime(dtA);
int nD3 = cal.get(Calendar.DATE); // Day Of Month + 1 day
System.out.println(nD3+" nD3");


141

Create monochromatic bitmap Android example | create-monochromatic-bitmap-android-example



public class MainActivity extends Activity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new SampleView(this));
	}

	private static class SampleView extends View {

		// CONSTRUCTOR
		public SampleView(Context context) {
			super(context);
			setFocusable(true);

		}
		@Override
		protected void onDraw(Canvas canvas) {
			Paint paint = new Paint();
			
			canvas.drawColor(Color.GREEN);
            
            Bitmap b = Bitmap.createBitmap(200, 200, Bitmap.Config.ALPHA_8);
             paint.setColor(Color.BLUE);
            
           Canvas c = new Canvas(b);
           c.drawRect(0, 0, 200, 200, paint);
           
           canvas.drawBitmap(b, 10,10, paint);
		}

	}
}



monochromatic bitmap


Editace Jana Žákovská : 2012-02-02 08:58:22
Počet článků v kategorii: 397
Url:android-java-functions-samples
Share
Share
Tweet