开发者

Sub activity confusion. Multiple programs being compiled

I'm having great problems with getting subactivities to work properly. I've read several tutorials on the subject, none of which work, or seem to leave out important info on how to setup the call to the sub activity.

All I want to do is launch a sub-activity. The calling activity doesn't need to get any info back from the called activity.

What I've got so far:

Calling code:

final Intent intent = new Intent();
    intent.setClass(this, voltageDivider.class);
    startActivity(intent);

Code called:

static public class voltageDivider extends Activity {

 public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 setContentView(R.layout.voltagedi开发者_Go百科vider);

Manifest.xml:

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

The code that's called is within the 'main' class of the program. This works as I want, as it starts a new activity which, when pressing back goes back to the calling activity, but each sub-activity is being compiled as a seperate application. It means I'll end up having about 20 icons in the program launcher screen, which I don't want. I just want one which is the main screen.

What am I doing wrong? How do I sort it out? The code I've ended up with is a result of it being the only way it will compile. For instance, final, static modifiers and the way the subactivity is defined in the manifest


What exactly is below this line in your manifest?

<activity android:name="main$ledResistorCalculator">

If you have an intent filter inside the activity tag, put it out so the activity tag looks like this:

<activity android:name="main$ledResistorCalculator" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜