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.

AlertDialog - MessageBox - Alert - Toast - Android sample



AlertDialog like MessageBox by WinApi:
If error: Unable to add window -- token null is not for an application
try change get Context.

// you can put this text into some function body or case in switch statement
                new AlertDialog.Builder(this)
                    .setMessage("Hello boys!!!")
                    .setPositiveButton("OK", null)
                    .show();



Context context = getApplicationContext();
	AlertDialog.Builder builder = new AlertDialog.Builder(context);
	builder.setTitle("Select font size");
	final CharSequence[] chsSize= { "Small", "Medium", "Large"};
	builder.setSingleChoiceItems(chsSize, 0 /*sel.item*/, 
	new DialogInterface.OnClickListener() {
 	    public void onClick(DialogInterface dialog, int item) {
	    		 Toast.makeText(context, "Hello from dialog!!!", Toast.LENGTH_SHORT).show();
	        dialog.dismiss();
	    }
	});
	AlertDialog alert = builder.create();
	alert.show();
    

397LW NO topic_id



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


241

Admob ads not visible on emulator Android 4.1 | admob-ads-not-visible-on-emulator-android-4-1


If you using GoogleAdMobAdsSdk-4.0.4.jar in your project and set android:targetSdkVersion="17" in AndroidManifest.xml , ads will not visible on emulator with Android 4.0.3 or 4.1.
You have to set as android:targetSdkVersion="17"


<uses-sdk android:minSdkVersion="4" 
        android:targetSdkVersion="17" />


Update project.properties file - row with target to 17:

# Project target.
target=android-17
385

EditText hint not show | edittext-hint-not-show


Try this solution - into xml file add row to EditText tag:


android:textColorHint="@color/grey"

391

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

364

Android Studio gradle file comment same as java comment | android-studio-gradle-file-comment-same-as-java-comment



// single line
/*
multi line
*/
93

Android Emulator PC keyboard shortcuts | android-emulator-pc-keyboard-shortcuts


Basic shortcuts for Android Emulator.
























Emulated Device Key Keyboard Key
Home HOME
Menu (left softkey) F2 or Page-up button
Star (right softkey) Shift-F2 or Page Down
Back ESC
Call/dial button F3
Hangup/end call button F4
Search F5
Power button F7
Audio volume up button KEYPAD_PLUS, Ctrl-5
Audio volume down button KEYPAD_MINUS, Ctrl-F6
Camera button Ctrl-KEYPAD_5, Ctrl-F3
Switch to previous layout orientation (for example, portrait, landscape) KEYPAD_7, Ctrl-F11
Switch to next layout orientation (for example, portrait, landscape) KEYPAD_9, Ctrl-F12
Toggle cell networking on/off F8
Toggle code profiling F9 (only with -trace startup option)
Toggle fullscreen mode Alt-Enter
Toggle trackball mode F6
Enter trackball mode temporarily (while key is pressed) Delete
DPad left/up/right/down KEYPAD_4/8/6/2
DPad center click KEYPAD_5
Onion alpha increase/decrease KEYPAD_MULTIPLY(*) / KEYPAD_DIVIDE(/)


More about Android Emulator


Editace Jana Žákovská : 2011-10-27 20:09:56
Počet článků v kategorii: 397
Url:alertdialog-like-messagebox-android-sample
Share
Share
Tweet