Pergunta

Noob alert! I started my current app as a simple test activity running the main routine. I now want to turn it into a proper app which requires a main menu as the main_activity to call the sub activity with appropriate parameters.

I'm used to simple coding where you just rename files, but in Eclipse you need to do things in particular ways I've noticed. So what's the proper procedure for shifting my current main_activity to a lower level and replacing the main_activity? Is it just a case of creating the lower activities and then copy/pasting code and .xml files, and then overwriting main_activity? Or should I refactor things in a particular order to keep the manifest and such in order?

Foi útil?

Solução

Your question is a little confusing and I'm not 100% sure this is answering it but here are some tidbits:

Your 'main' activity (entry into the application) is determined by the activity which provides a LAUNCHER intent-filter in AndroidManifest.xml

In that file, you'll see an activity with the added lines

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

This says that whichever activity this is - launch it when the app icon is hit.

There aren't really sub-activities (at least not in the way you're talking about them). Activities represent different screens that are displayed to the user and to call one from another you use an Intent. If you want to pass data to the called Activity, look into Intent.putExtra and/or Bundles.

As far as renaming, simply right click on a source file in Eclipse and choose refactor->rename. This will grep your project and do a find/replace on all your uses of the old name.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top