PDA

Ver la Versión Completa : nuevo en android...


kyocera
08/03/11, 17:48:36
Hola buenas a todos, soy nueva en esto de la programación con android, estoy creando un sudoku... como ejercicio para coger soltura y ver como funcionan las cosas.

Pero al ejecutar la aplicación me sale este error y no se a que se debe...

El mensaje que me muestra la aplicación es que el programa se tuvo que cerrar inesperadamente.

y cuando lo depuro el mensaje que me sale es este...

Source not Found

the source attachement does not contain the source for the file InvocationTargetException.class

se que el error es que no encuentra el archivo pero donde esta ese archivo??

este es el código donde salta el error

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);


// Listener for the buttons

View continueButton= findViewById(R.id.continue_button);
continueButton.setOnClickListener(this);

View newButton= findViewById(R.id.new_button);
newButton.setOnClickListener(this);

View aboutButton=findViewById(R.id.about_button);
aboutButton.setOnClickListener(this);

View exitButton= findViewById(R.id.exit_button);
exitButton.setOnClickListener(this);


}

public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.about_button:
Intent i= new Intent(this, About.class);
startActivity(i);
break;

default:
break;
}

Espero que me podais ayudar.

Un saludo y felicidades por el foro.

mekawendie
10/03/11, 15:23:53
No tengo mucho tiempo ahora que ya me piro pero tienes en el AndroidManifest.xml la clase que quierse mostrar???
<activity android:name=".About" />

Me cuentas y lo miramos luego !!!
Talue!

kyocera
10/03/11, 18:24:04
gracias por responder mekawendie si si tengo la activity añadida al AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sudoku"
android:versionCode="1"
android:versionName="1.0">


<application android:icon="drawable/icon" android:label="string/app_name">
<activity android:name=".Sudoku"
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=".About"
android:label="string/about_text"
android:theme="android:style/Theme.Dialog">
</activity>
</application>
</manifest>

mekawendie
10/03/11, 19:28:06
Pues no se... yo me he creado un ejemplo con tu código y me funciona...

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.me.androcronometro"
android:versionCode="1"
android:versionName="1.0">

 
<application android:icon="drawable/icon" android:label="string/app_name">
<activity android:name=".MainActivity"
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=".About"
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>


MainActivity.java

public class MainActivity extends Activity implements OnClickListener{

public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// Listener for the buttons
View continueButton= findViewById(R.id.button);
continueButton.setOnClickListener(this);

View newButton= findViewById(R.id.button);
newButton.setOnClickListener(this);

View aboutButton=findViewById(R.id.button);
aboutButton.setOnClickListener(this);

View exitButton= findViewById(R.id.button);
exitButton.setOnClickListener(this);
}

public void onClick(View v)
{
// TODO Auto-generated method stub
switch (v.getId())
{
case R.id.button:
Intent i= new Intent(this, About.class);
startActivity(i);
break;

default:
break;
}
}
}


About.Java

public class About extends Activity{

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);
}
}



Depura paso a paso y a ver qué es lo que te pasa... :pensando: