Hi, I have just start to develop android, and I just cannot start my
Hello World application.
I have followed instructions about android installation, I have
changed several Eclipse IDE's, but still, when I press f11 to compile,
it 'does' some job int he background, activate my virtual device, but
wont to behave just as it should!
Only " Android . . . " is displayed on the screen, which mean that my
class isn't 'loaded', somehow.
This is sample class :
view plaincopy to clipboardprint?
1. package test.and;
2. import android.app.Activity;
3. import android.os.Bundle;
4. import android.view.View;
5. import android.widget.Button;
6. import android.widget.EditText;
7. import android.widget.TextView;
8.
9.
10. public class TestAppActiv extends Activity {
11. Button button1;
12. EditText txtbox1,txtbox2;
13. TextView tv;
14.
15. /** Called when the activity is first created. */
16. @Override
17. public void onCreate(Bundle savedInstanceState) {
18. super.onCreate(savedInstanceState);
19. setContentView(R.layout.main);
20. txtbox1= (EditText) findViewById(R.id.txtbox1);
21. button1 = (Button) findViewById(R.id.button1);
22. tv = (TextView) findViewById(R.id.lbl1);
23. txtbox2= (EditText) findViewById(R.id.txtbox2);
24. button1.setOnClickListener(new Clicker());
25. }
26. class Clicker implements Button.OnClickListener
27. {
28. public void onClick(View v)
29. {
30. String a,b;
31. Integer vis;
32. a = txtbox1.getText().toString();
33. b = txtbox2.getText().toString();
34. vis = Integer.parseInt(a)+Integer.parseInt(b);
35. tv.setText(vis.toString());
36. }
37. }
38. }
package test.and; import android.app.Activity; import
android.os.Bundle; import android.view.View; import
android.widget.Button; import android.widget.EditText; import
android.widget.TextView; public class TestAppActiv extends Activity
{ Button button1; EditText txtbox1,txtbox2; TextView tv; /** Called
when the activity is first created. */ @Override public void
onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState); setContentView(R.layout.main);
txtbox1= (EditText) findViewById(R.id.txtbox1); button1 = (Button)
findViewById(R.id.button1); tv = (TextView) findViewById(R.id.lbl1);
txtbox2= (EditText) findViewById(R.id.txtbox2);
button1.setOnClickListener(new Clicker()); } class Clicker implements
Button.OnClickListener { public void onClick(View v) { String a,b;
Integer vis; a = txtbox1.getText().toString(); b =
txtbox2.getText().toString(); vis = Integer.parseInt(a)
+Integer.parseInt(b); tv.setText(vis.toString()); } } }
And, also main.xml file, which reflect contains xml representation of
display window :
main.xml :
view plaincopy to clipboardprint?
1. <?xml version="1.0" encoding="utf-8"?>
2. <AbsoluteLayout
3. android:id="@+id/widget35"
4. android:layout_width="fill_parent"
5. android:layout_height="fill_parent"
6. xmlns:android="http://schemas.android.com/apk/res/android"
7. >
8. <EditText
9. android:id="@+id/txtbox1"
10. android:layout_width="145px"
11. android:layout_height="40px"
12. android:text="EditText"
13. android:textSize="18sp"
14. android:layout_x="75px"
15. android:layout_y="54px"
16. >
17. </EditText>
18. <EditText
19. android:id="@+id/txtbox2"
20. android:layout_width="144px"
21. android:layout_height="40px"
22. android:text="EditText"
23. android:textSize="18sp"
24. android:layout_x="75px"
25. android:layout_y="109px"
26. >
27. </EditText>
28. <Button
29. android:id="@+id/button1"
30. android:layout_width="106px"
31. android:layout_height="36px"
32. android:text="Button"
33. android:layout_x="88px"
34. android:layout_y="224px"
35. >
36. </Button>
37. <TextView
38. android:id="@+id/lbl1"
39. android:layout_width="141px"
40. android:layout_height="wrap_content"
41. android:text="TextView"
42. android:layout_x="76px"
43. android:layout_y="166px"
44. >
45. </TextView>
46. </AbsoluteLayout>
<?xml version="1.0" encoding="utf-8"?> <AbsoluteLayout android:id="@
+id/widget35" android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://
schemas.android.com/apk/res/android" > <EditText android:id="@+id/
txtbox1" android:layout_width="145px" android:layout_height="40px"
android:text="EditText" android:textSize="18sp"
android:layout_x="75px" android:layout_y="54px" > </EditText>
<EditText android:id="@+id/txtbox2" android:layout_width="144px"
android:layout_height="40px" android:text="EditText"
android:textSize="18sp" android:layout_x="75px"
android:layout_y="109px" > </EditText> <Button android:id="@+id/
button1" android:layout_width="106px" android:layout_height="36px"
android:text="Button" android:layout_x="88px" android:layout_y="224px"
> </Button> <TextView android:id="@+id/lbl1"
android:layout_width="141px" android:layout_height="wrap_content"
android:text="TextView" android:layout_x="76px"
android:layout_y="166px" > </TextView> </AbsoluteLayout>
then, strings.xml :
view plaincopy to clipboardprint?
1. <?xml version="1.0" encoding="utf-8"?>
2. <resources>
3. <string name="hello">Hello World, TestAppActiv!</string>
4. <string name="app_name">TestApp</string>
5. </resources>
<?xml version="1.0" encoding="utf-8"?> <resources> <string
name="hello">Hello World, TestAppActiv!</string> <string
name="app_name">TestApp</string> </resources>
AndroidManifest.xml :
view plaincopy to clipboardprint?
1. <?xml version="1.0" encoding="utf-8"?>
2. <manifest xmlns:android="http://schemas.android.com/apk/res/
android"
3. package="test.and"
4. android:versionCode="1"
5. android:versionName="1.0">
6. <application android:icon="@drawable/icon"
android:label="@string/app_name">
7. <activity android:name=".TestAppActiv"
8. android:label="@string/app_name">
9. <intent-filter>
10. <action
android:name="android.intent.action.MAIN" />
11. <category
android:name="android.intent.category.LAUNCHER" />
12. </intent-filter>
13. </activity>
14.
15. </application>
16.
17.
18. </manifest>
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://
schemas.android.com/apk/res/android" package="test.and"
android:versionCode="1" android:versionName="1.0"> <application
android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".TestAppActiv" android:label="@string/
app_name"> <intent-filter> <action
android:name="android.intent.action.MAIN" /> <category
android:name="android.intent.category.LAUNCHER" /> </intent-filter> </
activity> </application> </manifest>
and default.properties file :
view plaincopy to clipboardprint?
1. # This file is automatically generated by Android Tools.
2. # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3. #
4. # This file must be checked in Version Control Systems.
5. #
6. # To customize properties used by the Ant build system use,
7. # "build.properties", and override values to adapt the script to
your
8. # project structure.
9.
10. # Project target.
11. target=android-3
# This file is automatically generated by Android Tools. # Do not
modify this file -- YOUR CHANGES WILL BE ERASED! # # This file must be
checked in Version Control Systems. # # To customize properties used
by the Ant build system use, # "build.properties", and override values
to adapt the script to your # project structure. # Project target.
target=android-3
Just as I said, I did install everything I needed (SDK, ADT plugin,
etc...), but it still wont work
I appreciate any help!
Thanks
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en