I dont understand what seems to be the problem here...my app just crashes. And i get the followin logcat error: ERROR/dalvikvm(1270): Could not find class 'intentTest.xyz.com.second', referenced from method intentTest开发者_运维百科.xyz.com.intentTest$1.onClick
1.intentTest.java:
package intentTest.xyz.com;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class intentTest extends Activity {
Button b;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
b = (Button) findViewById(R.id.b);
b.setOnClickListener( new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent(intentTest.this,second.class );
startActivity(intent);
}
});
}
}
2.main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="First screen"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="map"
android:id="@+id/b"
/>
</LinearLayout>
3.second.java:
package intentTest.xyz.com;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
public class second extends MapActivity{
MapView map;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
map = (MapView) findViewById(R.id.map);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
4.second.xml:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="0ujyc9Tw2cYvyPECIKTQIK0pwuL-UPa_sh4BpIw"
/>
5.manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="intentTest.xyz.com"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".intentTest"
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=".second"
android:label="@string/app_name">
<uses-library android:name="com.google.android.maps" />
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
never mind...i rewrote the whole code....step by step...complied it and then got the out put....probably a complier problem
精彩评论