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.

Draw Path drawPath draw the trajectory of shot Android basic example


AD MOB

Draw the trajectory of shot.

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);

		}
	       private static void makePath(Path p) {
	            p.moveTo(10, 0);
	            p.cubicTo(100, -50, 200, 150, 300, 0);
	        }
		@Override
		protected void onDraw(Canvas canvas) {

			canvas.drawColor(Color.CYAN);
			Paint p = new Paint();
			// smooths
			p.setAntiAlias(true);
			p.setColor(Color.RED);
			p.setStyle(Paint.Style.STROKE); 
			p.setStrokeWidth(5);
			// opacity
			//p.setAlpha(0x80);
 
			p.setColor(Color.BLACK);
			Path mPath = new Path();
            makePath(mPath);
			canvas.drawPath(mPath, p); //(rectF, 90, 45, true, p);
		}

	}
}

397LW NO topic_id




AD

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


0

EditText text changed java Android | edittext-text-changed


Google Android example source code - is text changed in EditText ?

EditText hEditText;

// TextChanged in onCreate
hEditText = (EditText)findViewById(R.id.idEditText);
hEditText.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable str) {
}

public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}

public void onTextChanged(CharSequence sq, int start, int before,
int count) {
}
});
295

Shuffle array int string Java Android | shuffle-array-int-string-java-android



String [] arOfStrings = {"one", "two", "three"};
List<String> mListOfStrings = new ArrayList<String>(Arrays.asList(arOfStrings));
Collections.shuffle(mListOfstrings);
String str = mListOfStrings.get(2);// 2 is index of pozition an element


int [] arOfInt = {1, 2, 3};
List<Integer> mListOfInt = new ArrayList<Integer>(Arrays.asList(arOfInt));
Collections.shuffle(mListOfInt);
97

How going life cycle if screen orientation changed Android example | how-going-life-cycle-if-screen-orientation-changed-android-example


onSaveInstanceState, onRestoreInstanceState life cycle if screen orientation changed from log file.

// starts activity
15:27:12.801: INFO/onCreate(1828): onCreate()
15:27:12.811: INFO/onStart(1828): onStart()
15:27:12.821: INFO/onResume(1828): onResume()
// activity is running 

15:27:33.651: DEBUG/dalvikvm(307): GC_EXPLICIT freed 186K, 53% 
free 2770K/5831K, external 981K/1038K, paused 99ms

// change emulator state Ctrl+F11 landscape, portrait
15:27:40.427: INFO/ActivityManager(74): Config changed: 
{ scale=1.0 imsi=310/260 loc=en_US touch=3 keys=2/1/2 nav=3/1 orien=2 layout=18 uiMode=17 seq=64}

// saved all variable values if need
15:27:40.581: INFO/onSaveInstanceState(1828): onSaveInstanceState()

15:27:40.602: INFO/onPause(1828): onPause()
15:27:40.612: INFO/onStop(1828): onStop()
15:27:40.631: INFO/onDestroy(1828): onDestroy()

// activity goes back to onCreate !!!!!!!!!
15:27:40.692: INFO/onCreate(1828): onCreate()
15:27:40.701: INFO/onStart(1828): onStart()

// restore all saved values of variables 
15:27:40.711: INFO/onRestoreInstanceState(1828): onRestoreInstanceState()
// you can using saved values by onSaveInstanceState() in onResume
15:27:40.721: INFO/onResume(1828): onResume()




Diagram of life cycle onSaveInstanceState, onRestoreInstanceState

[caption id="attachment_1169" align="alignleft" width="229" caption="Life cycle onRestoreInstanceState"]life_cycle_onRestoreInstanceState[/caption]
166

Multiple substitutions specified in non-positional format | multiple-substitutions-specified-in-non-positional-format


Multiple substitutions specified in non-positional format;did you mean to add the formatted="false" attribute?
Wiktionary, WiktionarySimple
location C:\documents\WiktionarySimple\res\values\strings.xml
Issue:


    <string name="template_user_agent">"%s/%s (Linux; Android)"</string>
    <string name="template_wotd_title">"Wiktionary:Word of the day/%s %s"</string>
    <string name="template_define_url">"//en.wiktionary.org/wiki/%s"</string>

Solution:

   <string name="template_user_agent" translatable="false">"%1$s/%2$s (Linux; Android)"</string>
    <string name="template_wotd_title">"Wiktionary:Word of the day/%1$s %2$s"</string>
    <string name="template_define_url" translatable="false">"//en.wiktionary.org/wiki/%s"</string>

268

setTesting(boolean) from the type AdRequest is deprecated | settestingboolean-from-the-type-adrequest-is-deprecated


Admob testing on emulator issue.
Android Eclipse code warning:
setTesting(boolean) from the type AdRequest is deprecated
Solution:
adRequest.addTestDevice(AdRequest.TEST_EMULATOR);


AdView adView = new AdView(this, AdSize.BANNER, "a14d9..........");//MY_AD_UNIT_ID
AdRequest adRequest = new AdRequest();
		adRequest.setTesting(true); // deprecated

		adRequest.addTestDevice(AdRequest.TEST_EMULATOR); // OK
		adView.loadAd(adRequest);



Editace: 2013-12-09 13:10:58
Počet článků v kategorii: 397
Url:draw-path-drawpath-android-basic-example

AD
11 Share
Share
Tweet