Я хочу сделать простое действие, в котором, когда я нажимаю кнопку, я должен перейти к другому действию.Но в этой программе всякий раз, когда я нажимаю кнопку отправки, происходит ошибка, и программа завершается.
Пожалуйста, проверьте мой код и помогите мне, какую ошибку я совершил.
Мое первое занятие
package login.test;
import android.app.Activity;
import android.os.Bundle;
import android.content.*;
import android.widget.*;
import android.view.View;
import android.view.View.OnClickListener;
public class login extends Activity
{
/** Called when the activity is first created. */
EditText e;
Button b;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
b=(Button)findViewById(R.id.submit);
e=(EditText)findViewById(R.id.editText1);
b.setOnClickListener( new OnClickListener()
{
@Override
public void onClick(View v)
{
if (v.getId() == R.id.submit)
{
Intent myIntent = new Intent(v.getContext(), some.class);
startActivityForResult(myIntent, 0);
}
else
{
e.setText("cant go");
}
}
});
}
}
второе Задание
package login.test;
import android.os.Bundle;
import android.app.Activity;
import android.content.*;
import android.widget.*;
import android.view.View;
import android.view.View.OnClickListener;
public class some extends Activity {
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome);
}
}
main.xml
<?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" android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="saan"
/>
<Button android:text="Submit" android:id="@+id/submit" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:text="EditText" android:id="@+id/editText1"></EditText>
</LinearLayout>
welcome.xml
<?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">
<EditText android:text="You are welcome" android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content"></EditText>
</LinearLayout>