Abrir diálogo a través del menú dinámico

How can I open a dialog with some html formatting and hypertext link support (open that link in default browser), when I click on item: "ABOUT" in my dynamically created menu? Also, how I can make SHARE function, so that if anybody click on: "SHARE" item, it will either share link to that APK, or send it over bluetooth?

This is what I have in MainActivity:

private static final int NEW_MENU_ID=Menu.FIRST+1;
@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);

        menu.add(0, NEW_MENU_ID, 0, "ABOUT");
        menu.add(0, NEW_MENU_ID, 0, "SHARE");

        return true;
    }

And this is how it should look like: plantilla

Gracias por ayudar!

preguntado el 24 de agosto de 12 a las 10:08

2 Respuestas

Actually, there's two big and completely different questions and too little code presented.

First of all You should give different options id in onCreateOptionsMenu (let them be ID_ABOUT == 0 and ID_SHARE == 1) override onOptionsItemSelected () Me gusta esto:

@Override
public boolean onOptionsItemSelected (MenuItem item) {
    switch(item.getItemId()) {
    case ID_ABOUT:
        handleAbout();
        break;

    case ID_SHARE:
        handleShare();
        break;
    }
}

No handleAbout() and handleShare() should be defined (that's your questions about):

  • ABOUT: probably, the easiest way is to create additional activity which would contain only one WebView. First activity would just start AboutActivity from handleAbout();
  • SHARE: it's quite common task. Please, refer to android documentation aquí and for example, to esta pregunta

contestado el 23 de mayo de 17 a las 11:05

1. how could I open dialog with some html formatting and hypertext link support (open that link in default browser), when I click on item: "ABOUT" in my dynamically created menu?

Look at this SO Question: No se puede hacer clic en los hipervínculos de Android en TextView en AlertDialog personalizado

2. how I can make SHARE function, so that if anybody click on: "SHARE" item, it will either share link to that APK, or send it over bluetooth?

Utilice las Intención de Android con Intent.ACTION_SEND. Which will share the link of .apk file on available application on device which handle SHARE Intent.

and to send APK via Bluetooth .. either use same Intención con ACTION_SEND action or You have to implement Bluetooth file transfer code..

Look at this SO Question: transferencia de archivos bluetooth en android

contestado el 23 de mayo de 17 a las 13:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.