0

请提出解决方案。当我单击下一个按钮时,它会给出运行时异常。我不知道如何解决这个问题。我尝试完全删除 java 代码并重新创建它。

代码如下。

package com.android.ewallet;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class Creataccount extends Activity
{
Intent i5;
Bundle b5=new Bundle();
ArrayList<String> value5=new ArrayList<String>();
public void onCreate(Bundle savedInsatnceState)
{
    super.onCreate(savedInsatnceState);
    setContentView(R.layout.creataccount);
    Button next5=(Button)findViewById(R.id.next5);
    Button plus5=(Button)findViewById(R.id.plus5);
    next5.setOnClickListener(new View.OnClickListener() {
                    @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                EditText acntheadet5=(EditText)findViewById(R.id.acntheadet5);
                if((acntheadet5.getText().toString()).equals(""))
                        {
                            Intent i50=new Intent(Creataccount.this,Addentry.class);                                         
                            //b5=getIntent().getExtras();

                            //i5.putExtras(b5);
                            startActivity(i50);

                        }
                else
                {
                    Toast.makeText(Creataccount.this, "Click on + to save your account", Toast.LENGTH_LONG).show();
                }
            }
        });

    Button back5= (Button)findViewById(R.id.back5);
    back5.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            i5=new Intent(Creataccount.this,OptionList.class);
            b5=getIntent().getExtras();
            i5.putExtras(b5);
            startActivity(i5);

        }
    });

    plus5.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
        EditText acntheadet5=(EditText)findViewById(R.id.acntheadet5);
        value5.add(acntheadet5.getText().toString());
        b5.putStringArrayList("key", value5);
        Toast.makeText(getBaseContext(), "Data saved" , Toast.LENGTH_LONG).show();
        acntheadet5.setText("");
        }
    });
    }
}

单击下一步按钮后,它应该启动 Addentry.java,其代码如下。

package com.android.ewallet;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
public class Addentry extends Activity
{
Intent i6;
Bundle b6=new Bundle();

public void onCreate(Bundle savedInstanceState)
{

    super.onCreate(savedInstanceState);
    setContentView(R.layout.addentry);

    final Spinner accnt6=(Spinner)findViewById(R.id.accnt6);
    Spinner frequencyet6=(Spinner)findViewById(R.id.frequencyet6);
    final EditText selectdateet6=(EditText)findViewById(R.id.selectdateet6);
    final EditText ammountet6=(EditText)findViewById(R.id.ammountet6);
    Button selectdate6=(Button)findViewById(R.id.selectdate6);
    Button add6=(Button)findViewById(R.id.add6);
    Button createaccount6=(Button)findViewById(R.id.createaccount6);
    createaccount6.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            i6=new Intent(Addentry.this,Creataccount.class);
//              b6=getIntent().getExtras();
//          i6.putExtras(b6);
            startActivity(i6);

        }
    });


    ArrayList<String> acchead=b6.getStringArrayList("key");
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, acchead);
    accnt6.setAdapter(adapter);

    String a6[]={"Monthly","Quarterly","HalfYearly","Yearly"};
    ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, a6);
    frequencyet6.setAdapter(adapter1);



    selectdate6.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v)
        {
            startActivityForResult((new Intent(Addentry.this,Date.class)),1);
        }
    });



    createaccount6.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v)
        {
            i6=new Intent(Addentry.this,Creataccount.class);
        //  b6=getIntent().getExtras();
            //i6.putExtras(b6);
            startActivity(i6);
        }
    });



    add6.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            //b6=getIntent().getExtras();
            //String s=b6.getString("LoginID");
            selectdateet6.getText().toString();
            accnt6.getSelectedItem();
            ammountet6.getText().toString();
            accnt6.getSelectedItem();
        }
    });

}

public void onActivityResult(int requestcode,int resultcode,Intent i)
{
    if(requestcode==1)
        if(resultcode==RESULT_OK)
        {`enter code here`
            final EditText selectdateet6=(EditText)findViewById(R.id.selectdateet6);
            selectdateet6.setText(i.getData().toString());
        }
}
}
4

0 回答 0