活動之間的切換我有一個運行時錯誤,當我按下應該更改活動按鈕:運行時錯誤而在Android的
package com.example.LocationTracker;
import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button;
public class LocationTracker extends Activity{ /** Called when the activity is first created. */
Button btn_Tracker;
Button btn_Display_Map;
Context context;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
context = getApplicationContext();
btn_Tracker = (Button)findViewById(R.id.btn_Tracker);
btn_Tracker.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//setContentView(R.layout.trackeractivity);
Intent myIntent1 = new Intent(view.getContext(), TrackerActivity.class);
context.startActivity(myIntent1);
}});
}
class TrackerActivity extends Activity {
//Your member variable declaration here
// Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.trackeractivity);
}
}
我就在maniefest文件
<activity android:name=".TrackerActivity" android:label="@string/app_name"/>
<activity android:name=".DisplayMapActivity" android:label="@string/app_name"/>
</application>
任何添加的一切理念?
我們可以得到logcat輸出嗎? – 2011-03-31 20:49:30
請給我們logcat消息! 「運行時錯誤」真的沒有幫助 – 2011-03-31 20:55:37