嘿傢伙我只是寫了一個名稱getter應用程序,因爲我學習的是android,當它加載到模擬器中時我被迫關閉應用程序。我很新,所以這可能很簡單。剛入門,我簡單的名字getter應用程序崩潰
namegetter.java
package edu.calpoly.android.lab1;
// tools
import android.app.Activity;
import android.content.Intent;
import android.content.pm.LabeledIntent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class NameGetter extends Activity implements android.view.View.OnClickListener{
// variables
private android.widget.EditText textEdit_Name;
private android.widget.Button button_Submit;
private String string_Name;
private android.content.Intent intent_GetText;
private android.os.Bundle bundle;
private android.widget.TextView textView_Top;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.name_getter);
// assign local variables
textEdit_Name = (EditText) this.findViewById(R.id.editText_Name);
button_Submit = (Button) this.findViewById(R.id.button_Submit);
textView_Top = (TextView) this.findViewById(R.id.LABEL1);
button_Submit.setOnClickListener(this);
bundle = this.getIntent().getExtras();
bundle.getString(string_Name);
textView_Top.setText(string_Name);
}
public void onClick(View v) {
string_Name = textEdit_Name.getText().toString();
// create intent to pass
intent_GetText= new Intent(this, HelloWorld.class);
// pass to hello world activity
intent_GetText.putExtra(string_Name, textEdit_Name.getText().toString());
// initiate
this.startActivity(intent_GetText);
}
}
的Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="edu.calpoly.android.lab1"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="12" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name="NameGetter"
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="HelloWorld" ></activity>
</application>
</manifest>
難道您發佈logcat的? 「adb logcat> file_to_write.to」 –
另外,您的name_getter.xml文件 –