-2

I am using Win 7.0, Eclipse and android SDK. I want to add new activity in AndroidManifest.xml Application tab as it is shown in this tutorial Android Development – Adding Screens & Button Handlers

I add an Activity name to my manifest but it does not automatically turn it into a link. e.g. I cannot click the "Name"(It is not a hyperlink as shown in the article), thus I cannot create my class.

Can You Help me? what is the problem ?

rf43
  • 4,385
  • 3
  • 23
  • 28
atromgame
  • 434
  • 2
  • 12
  • 24
  • Can you please clean up your question and provide the suspect code from your `AndroidManifest.xml`? It's very difficult to determine what you need. – thegrinner Jul 22 '11 at 17:37
  • Confusing question. I think I understood the general problem (add a new activity, I guess), but I have no idea if it's in the manifest (only?), what is the problem in the manifest, and if you added the java file already. Improve your communications skills/eloquence a bit, if you can. – davidcesarino Jul 22 '11 at 17:41
  • Please look this image http://94.78.74.150/aa.jpg , you see red arrow to show Name as UNLink – atromgame Jul 22 '11 at 17:55
  • @atromgame Now, with that picture, it makes less sense... what are you trying to accomplish? – rf43 Jul 22 '11 at 18:05
  • You have to create a class that extends Activity first, then you can add it to your manifest. – Michael B. Jul 22 '11 at 18:10
  • @DDoSAttack, please look this image too, http://94.78.74.150/bb.jpg – atromgame Jul 22 '11 at 18:11
  • @DDoSAttack , Orginal image form http://www.barebonescoder.com/2010/05/android-development-adding-screens-button-handlers/ – atromgame Jul 22 '11 at 18:12
  • Did you see what I am saying, in my Eclipse , Name is not Clickable, But other image (bb.jpg) clicable and when you click on it Eclipse create automatic the class and OnCreate functions – atromgame Jul 22 '11 at 18:13
  • BTW for the record... That is REALLY bad tutorial!!! Whoever made that really needs to learn standard OOP practices and how to properly program for Android... who the hell names their class "screen1"[sic]??? and even worse, who names an Android Activity "main"[sic]??? – rf43 Jul 22 '11 at 18:15
  • That tutorial even says to create the class first. – Rob Jul 22 '11 at 18:24
  • Yes you are right, but I dont understand why looking unlink in my ecplise. May be diffrent eclipse or android version. I hope that you understand me. – atromgame Jul 22 '11 at 18:30
  • That is odd. Try reinstalling the ADT plugin? – Rob Jul 22 '11 at 18:35
  • It's definitely a different version of the ADT plugin. You have a field "VM Safe Mode" and "Restore Any Version" which aren't in the bb screenshot, nor on my screen. – Rob Jul 22 '11 at 18:38
  • Possible duplicate of [Best way to add Activity to an Android project in Eclipse?](http://stackoverflow.com/questions/2337874/best-way-to-add-activity-to-an-android-project-in-eclipse) – Edward Falk Mar 29 '16 at 19:45

3 Answers3

2

1.Go to the Androidmanifest.xml file and add the activity inside the tag if your activity name is secondAct.

2.Create a class named secondAct.

<application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".Project1Activity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".secondAct"></activity>
        <activity android:name=".third"></activity>
    </application>

3 . if you are using a button for going to next activity, use the following code in secondAct.java

Button fbtn=(Button)findViewById(R.id.sbtn);
        fbtn.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub

                Intent sec=new Intent(secondAct.this,com.asish.third.class);
                startActivity(sec);

            }
        });
Asish AP
  • 4,421
  • 2
  • 28
  • 50
  • hi i saw your image , in the image below there is a last tab named Androidmanifest.xml, where you can add the above xml code. – Asish AP Jul 22 '11 at 18:05
1

Go to the small tab underneath that says AndroidManifest.xml and shows you the XML code for it. It should look like this:

<application android:label="@string/app_name" android:icon="@drawable/icon">
    <activity android:name=".ApplicationName"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".AnotherActivity"></activity>

</application>

Okay, click on ADD, then select the top box that says "Create a new element at the top level, in Application" and then you should get a box with linkable NAME*.

Rob
  • 2,779
  • 5
  • 23
  • 34
  • not with code, I want to automatic create class, Please look this image http://94.78.74.150/aa.jpg , you see red arrow , Name is not LINK – atromgame Jul 22 '11 at 17:57
  • Have you made the class yet? It won't make the class for you. – Rob Jul 22 '11 at 18:04
  • Please look this image too http://94.78.74.150/bb.jpg, As you see, Name is clickable , but first image( aa.jpg) Name is not clicable, When you click Name , eclipse open Class windows and its create class and oncreate function, Did you understand me ? – atromgame Jul 22 '11 at 18:16
0

You need to create the class first, then point to that class in your manifest... just putting the class name in the manifest is not enough. It will not automatically create it for you.

Also, it is easier to create the class first because then Eclipse will autocomplete the class name/path for you.

EDIT: AH HAH! I see what link you are talking about... Yeah, you need to actually create the class first for that to appear.

rf43
  • 4,385
  • 3
  • 23
  • 28
  • No I see internet eclipse create automatic class and Oncreate function, Please look http://94.78.74.150/aa.jpg , you see red arrow then NOT clickable, NOT Link, but I see on internet that the NAME is LİNK and eclipse create automatic the activity class and function – atromgame Jul 22 '11 at 18:05
  • That is not correct... you need to go to "File">"New">"Class" then extend Activity and it will automatically create the proper class with the onCreate() method. THEN you go to the manifest and put the Activity in there. – rf43 Jul 22 '11 at 18:08