80,472
社区成员




package com.example.helloworld;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Main extends Activity {
private Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button =(Button)this.findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setClass(Main.this,OtherActivity.class);
OtherActivity.name="jack";
OtherActivity.age=13;
startActivity(intent);
}
});
}
}
package com.example.helloworld;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class OtherActivity extends Activity {
private TextView textView;
public static String name;
public static int age;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.other);
textView = (TextView)this.findViewById(R.id.msg);
textView.setText("-name->>"+name+"\n"+"-age-->>"+age);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button android:id="@+id/button" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="使用静态变量传递数据" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/msg" android:layout_width="fill_parent"
android:layout_height="fill_parent" />"
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.helloworld"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="20" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Main"
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=".OtherActivity">
</activity>
</application>
</manifest>
03-27 04:10:32.950: D/dalvikvm(653): Not late-enabling CheckJNI (already on)
03-27 04:10:33.710: D/AndroidRuntime(653): Shutting down VM
03-27 04:10:33.710: W/dalvikvm(653): threadid=1: thread exiting with uncaught exception (group=0xb4a17d70)
03-27 04:10:33.740: E/AndroidRuntime(653): FATAL EXCEPTION: main
03-27 04:10:33.740: E/AndroidRuntime(653): Process: com.example.helloworld, PID: 653
03-27 04:10:33.740: E/AndroidRuntime(653): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.helloworld/com.example.helloworld.Main}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
03-27 04:10:33.740: E/AndroidRuntime(653): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
03-27 04:10:33.740: E/AndroidRuntime(653): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
03-27 04:10:33.740: E/AndroidRuntime(653): at android.app.ActivityThread.access$800(ActivityThread.java:138)
03-27 04:10:33.740: E/AndroidRuntime(653): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
03-27 04:10:33.740: E/AndroidRuntime(653): at android.os.Handler.dispatchMessage(Handler.java:102)
03-27 04:10:33.740: E/AndroidRuntime(653): at android.os.Looper.loop(Looper.java:136)
03-27 04:10:33.740: E/AndroidRuntime(653): at android.app.ActivityThread.main(ActivityThread.java:5026)
03-27 04:10:33.740: E/AndroidRuntime(653): at java.lang.reflect.Method.invokeNative(Native Method)
03-27 04:10:33.740: E/AndroidRuntime(653): at java.lang.reflect.Method.invoke(Method.java:515)
03-27 04:10:33.740: E/AndroidRuntime(653): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
03-27 04:10:33.740: E/AndroidRuntime(653): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
03-27 04:10:33.740: E/AndroidRuntime(653): at dalvik.system.NativeStart.main(Native Method)
03-27 04:10:33.740: E/AndroidRuntime(653): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
03-27 04:10:33.740: E/AndroidRuntime(653): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
03-27 04:10:33.740: E/AndroidRuntime(653): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
03-27 04:10:33.740: E/AndroidRuntime(653): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
03-27 04:10:33.740: E/AndroidRuntime(653): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
03-27 04:10:33.740: E/AndroidRuntime(653): at android.app.Activity.setContentView(Activity.java:1930)
03-27 04:10:33.740: E/AndroidRuntime(653): at com.example.helloworld.Main.onCreate(Main.java:17)
03-27 04:10:33.740: E/AndroidRuntime(653): at android.app.Activity.performCreate(Activity.java:5242)
03-27 04:10:33.740: E/AndroidRuntime(653): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-27 04:10:33.740: E/AndroidRuntime(653): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
03-27 04:10:33.740: E/AndroidRuntime(653): ... 11 more
03-27 04:15:34.060: I/Process(653): Sending signal. PID: 653 SIG: 9