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 yes no - Alert - Messagebox - Android sample

Dialog Yes No sample code

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure you want to exit application?")
       .setCancelable(false)
       .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int id) {
                MyActivity.this.finish(); //Close  this Activity for example: MyActivity.java
           }
       })
       .setNegativeButton("No", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int id) {
                // some code if you want
                dialog.cancel();
           }
       });
AlertDialog alert = builder.create();
alert.show();

396LW NO topic_id




AD

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


110

Create Button and TextView dynamically - Android sample | create-button-dynamically-android-sample



public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
            TextView textView = new TextView(this);
            textView.setText("Text View ");
            LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.FILL_PARENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT
            );
            layout.addView(textView, p);

            Button buttonView = new Button(this);
            buttonView.setText("Button");
            buttonView.setOnClickListener(mThisButtonListener);
            layout.addView(buttonView, p);
        
    }
    private OnClickListener mThisButtonListener = new OnClickListener() {
        public void onClick(View v) {
            Toast.makeText(MainActivity.this, "Hello !",
                    Toast.LENGTH_LONG).show();
        }
    };
}
354

Android Studio formatting code Ctrl + Alt + L | android-studio-formatting-code-ctrl-alt-l


Shortcut
Windows
Ctrl + Alt + L (format selection or all page)
Ctrl + Alt + Shift + L (show a dialog)
Linux
Ctrl + Windows Key + Alt + L

From menu Code
Code > Reformat Code
39

How setup color coloring syntax code highlight highlighting in Eclipse editor Android example | how-setup-color-syntax-highlight-in-eclipse-android-example


How setup color coloring highlight highlighting syntax font size and family in Eclipse Java and XML editor Android example
Java editor

  1. Go to Eclipse menu Window -> Preferences

  2. Doubleclick on Java

  3. Double click on Editor

  4. Select Java, Javadocs or Comments and setup color and font

  5. Font size and family change from Window->Preferences-> General->Appearance->Colors and Fonts


  6. Press OK for saving changes


xml editor
xml editor double click in Preferences dialog on xml -> Editor -> Syntax coloring
[caption id="attachment_627" align="alignleft" width="297" caption="Eclipse editor syntax color settings"]android/eclipse-color-syntax-highlight-settings-297x300.png[/caption]
21

How to install mount SD card for Eclipse Android Emulator | how-install-sd-card-on-android-eclipse-emulator


If you want download some *.apk file from internet and try on your emulator you get error than you have to install SD card. You have to closing Android emulator.
Mount Android emulator SD card instruction

  1. In Eclipse go in menu Window - Android SDK and Avg Manager

  2. Select Virtual devices

  3. Select AVD Name where you need install SD card

  4. Click on Edit button

  5. In open dialog go to SD card - Size: and write 500

  6. Press button Edit AVD

  7. Run AVD emulator


Image how install SD card on Android emulator in Eclipse.