Android运行时错误:无法封送值

Android运行时错误:无法封送值,android,bundle,serializable,Android,Bundle,Serializable,我这次使用的是可序列化接口。我想将ArrayList从一个活动传递到另一个活动,但它给了我一个错误“无法封送值”,代码是 //发送活动: public class LogIn extends Activity implements OnClickListener { ProgressDialog pd; ImageButton logIn,registr; EditText userName,Password; public static Str

我这次使用的是可序列化接口。我想将ArrayList从一个活动传递到另一个活动,但它给了我一个错误“无法封送值”,代码是

//发送活动:

    public class LogIn extends Activity implements OnClickListener
    {
    ProgressDialog pd;
    ImageButton logIn,registr;
    EditText userName,Password;
     public static String usrName,passwrd;
     String TAG=LogIn.class.getName();
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);
        userName=(EditText)findViewById(R.id.logIn_etuserName);
        Password=(EditText)findViewById(R.id.logIn_etpaswrd);
        logIn=(ImageButton)findViewById(R.id.logIn_B_logIn);
        registr=(ImageButton)findViewById(R.id.logIn_B_registration);       
        logIn.setOnClickListener(this);
        registr.setOnClickListener(this);

    }
    @Override
    public void onClick(View v)
    {

        String respns="";
        switch (v.getId())
        {
        case R.id.logIn_B_logIn:

            try 
            {
                usrName=userName.getText().toString();
                passwrd=Password.getText().toString();
                        if(usrName.contentEquals("") && passwrd.contentEquals(""))
                {
                    Toast.makeText(getApplicationContext(), "Enter       userName",Toast.LENGTH_LONG).show();
                }
      //                        else if(passwrd.contentEquals(""))
    //              {
    //                  Toast.makeText(getApplicationContext(), "Enter      password",Toast.LENGTH_LONG).show();
    //              }
                else
                {
                    pd=ProgressDialog.show(LogIn.this, "LogIn", "Logging");
                    new Athenticate().execute();


                }
            } catch (Exception e) 
            {
                e.printStackTrace();
            }
            break;
        case R.id.logIn_B_registration:
            Intent i=new Intent(LogIn.this,Registration.class);
            startActivity(i);
           break;
           default:
            break;
        }

    }

    private class Athenticate extends AsyncTask<String, Void,ArrayList<SettrGettr> >
    {
        ArrayList<SettrGettr> lst;

    @Override
    protected ArrayList<SettrGettr> doInBackground(String... params) 
    {
        lst=(ArrayList<SettrGettr>)new AllMethods().logInMethod();
        pd.cancel();
        return lst;
    }

    @Override
    protected void onPostExecute(ArrayList<SettrGettr> result) 
    {
        ArrayList<SettrGettr> l=result;
        try {
            if(l.size()>0)
            {
            Intent i=new Intent(LogIn.this,Home.class);
            Bundle b=new Bundle();
            b.putSerializable("shahid",l);
            //i.putExtras(b);
            i.putExtras(b);
            startActivity(i);
            }
            else
            {

            }
        } catch (Exception e) 
        {
        Log.d(TAG, "Errors are ::"+e.getMessage());
        }

    }




}


}

    //Recieving Activity:
        public class Home extends Activity implements Serializable
    {

    ListView lv;
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.home);
        lv=(ListView)findViewById(R.id.home_lv);

        ArrayList<SettrGettr> gtList=(ArrayList<SettrGettr>)getIntent().getSerializableExtra("shahid"); 
        //(ArrayList<SettrGettr>)getIntent().getSerializableExtra("shahid");

        ArrayAdapter<SettrGettr> adp=new ArrayAdapter<SettrGettr>(Home.this,android.R.layout.simple_list_item_1,gtList);
        lv.setAdapter(adp);


    }


}
//setterGettr:

public class SettrGettr {
    int ID;
    String Name = "";
    String FName = "";
    String Class = "";
    String UserName = "";
    String Password = "";
    String DOB = "";
    String MobileNo = "";
    String Relation = "";
    ArrayList<SettrGettr> msttrList;

    public ArrayList<SettrGettr> getMsttrList() {
        return msttrList;
    }

    public void setMsttrList(ArrayList<SettrGettr> msttrList) {
        this.msttrList = msttrList;
    }

    public int getID() {
        return ID;
    }

    public void setID(int iD) {
        ID = iD;
    }

    public String getName() {
        return Name;
    }

    public void setName(String name) {
        Name = name;
    }

    public String getFName() {
        return FName;
    }

    public void setFName(String fName) {
        FName = fName;
    }

    public String getCurrentClass() {
        return Class;
    }

    public void setClass(String class1) {
        Class = class1;
    }

    public String getUserName() {
        return UserName;
    }

    public void setUserName(String userName) {
        UserName = userName;
    }

    public String getPassword() {
        return Password;
    }

    public void setPassword(String password) {
        Password = password;
    }

    public String getDOB() {
        return DOB;
    }

    public void setDOB(String dOB) {
        DOB = dOB;
    }

    public String getMobileNo() {
        return MobileNo;
    }

    public void setMobileNo(String mobileNo) {
        MobileNo = mobileNo;
    }

    public String getRelation() {
        return Relation;
    }

    public void setRelation(String relation) {
        Relation = relation;
    }

    @Override
    public String toString() {

        return "\nRegistration No\t: " + getID() + "\n\nName\t\t\t\t\t\t\t: " + getName() + "\n\nFather Name\t\t\t: " + getFName() + "\n\nClass\t\t\t\t\t\t\t: "
                + getCurrentClass() + "\n\nCity\t\t\t\t\t\t\t\t: Islamabad" + "\n\nAdress\t\t\t\t\t\t: Islamabad";

    }

}
公共类登录扩展活动实现OnClickListener
{
进展性帕金森病;
ImageButton登录、注册;
编辑文本用户名、密码;
公共静态字符串usrName,passwrd;
String TAG=LogIn.class.getName();
@凌驾
创建时受保护的void(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
用户名=(EditText)findViewById(R.id.logIn\u etuserName);
密码=(EditText)findViewById(R.id.logIn_etpaswrd);
logIn=(ImageButton)findViewById(R.id.logIn\u B\u logIn);
registr=(ImageButton)findViewById(R.id.logIn\u B\u注册);
logIn.setOnClickListener(this);
registr.setOnClickListener(这个);
}
@凌驾
公共void onClick(视图v)
{
字符串respns=“”;
开关(v.getId())
{
案例R.id.logIn\u B\u登录:
尝试
{
usrName=userName.getText().toString();
passwrd=Password.getText().toString();
if(usrName.contentEquals(“”)和passwrd.contentEquals(“”)
{
Toast.makeText(getApplicationContext(),“输入用户名”,Toast.LENGTH_LONG.show();
}
//else if(passwrd.contentEquals(“”)
//              {
//Toast.makeText(getApplicationContext(),“输入密码”,Toast.LENGTH_LONG.show();
//              }
其他的
{
pd=ProgressDialog.show(LogIn.this,“LogIn”,“Logging”);
新的Athenticate().execute();
}
}捕获(例外e)
{
e、 printStackTrace();
}
打破
案例R.id.logIn\u B\u注册:
Intent i=新的Intent(LogIn.this、Registration.class);
星触觉(i);
打破
违约:
打破
}
}
私有类Athenticate扩展异步任务
{
ArrayList lst;
@凌驾
受保护的ArrayList doInBackground(字符串…参数)
{
lst=(ArrayList)new AllMethods().logInMethod();
pd.cancel();
返回lst;
}
@凌驾
受保护的void onPostExecute(ArrayList结果)
{
ArrayList l=结果;
试一试{
如果(l.size()>0)
{
意图i=新意图(LogIn.this、Home.class);
Bundle b=新Bundle();
b、 可编程(“shahid”,l);
//i、 putExtras(b);
i、 putExtras(b);
星触觉(i);
}
其他的
{
}
}捕获(例外e)
{
d(标记“错误为::”+e.getMessage());
}
}
}
}
//接收活动:
公共类Home extends活动实现可序列化
{
ListView lv;
@凌驾
创建时受保护的void(Bundle savedInstanceState)
{
//TODO自动生成的方法存根
super.onCreate(savedInstanceState);
setContentView(R.layout.home);
lv=(ListView)findViewById(R.id.home\u lv);
ArrayList gtList=(ArrayList)getIntent().GetSerializableTextra(“shahid”);
//(ArrayList)getIntent().getSerializableExtra(“shahid”);
ArrayAdapter adp=新的ArrayAdapter(Home.this,android.R.layout.simple\u list\u item\u 1,gtList);
低压设置适配器(adp);
}
}
//SetTargetTR:
公共类settrgetter{
int-ID;
字符串名称=”;
字符串FName=“”;
字符串类=”;
字符串UserName=“”;
字符串密码=”;
字符串DOB=“”;
字符串MobileNo=“”;
字符串关系=”;
ArrayList-msttrList;
公共阵列列表getMsttrList(){
返回msttrList;
}
public void setMsttrList(ArrayList msttrList){
this.msttrList=msttrList;
}
公共int getID(){
返回ID;
}
公共无效集合iD(内部iD){
ID=ID;
}
公共字符串getName(){
返回名称;
}
公共void集合名(字符串名){
名称=名称;
}
公共字符串getFName(){
返回FName;
}
公共void setFName(字符串fName){
FName=FName;
}
公共字符串getCurrentClass(){
返回舱;
}
公共void集合类(字符串类1){
类别=类别1;
}
公共字符串getUserName(){
返回用户名;
}
public void setUserName(字符串用户名){
用户名=用户名;
}
公共字符串getPassword(){
返回密码;
}
public void setPassword(字符串密码){
密码=密码;
}
公共字符串getDOB(){
返回DOB;
}
公共void setDOB(字符串dOB){
DOB=DOB;
}
公共字符串getMobileNo(){
返回MobileNo;
}
公共void setMobileNo(字符串mobileNo){
MobileNo=MobileNo;
}
公共字符串getRelation(){
回报关系;
}
公共void集合关系(字符串关系){
关系=关系;
}
@凌驾
公共字符串toString(){
返回“\n注册号\t:“+getID()+”\n\n名称\t\t\t\t\t\t:“+getName()+”\n\n文件夹名称\t\t\t:“+getFName()+”\n\n类\t\t\t\t\t\t:
+getCurrentClass()+“\n\nCity\t\t\t\t\t\t:Islamabad”+“\n\nAddress\t\t\t\t\t:Islamabad”;
}
}

做一件事,然后再试一次

public class Home extends Activity implements Serializable
从上面的行中删除
实现可序列化的

public class SettrGettr implements Serializable{
int ID;
String Name = "";
String FName = "";
String Class = "";
String UserName = "";
String Password = "";
String DOB = "";
String MobileNo = "";
String Relation = "";
ArrayList<SettrGettr> msttrList;

public ArrayList<SettrGettr> getMsttrList() {
    return msttrList;
}

public void setMsttrList(ArrayList<SettrGettr> msttrList) {
    this.msttrList = msttrList;
}

public int getID() {
    return ID;
}

public void setID(int iD) {
    ID = iD;
}

public String getName() {
    return Name;
}

public void setName(String name) {
    Name = name;
}

public String getFName() {
    return FName;
}

public void setFName(String fName) {
    FName = fName;
}

public String getCurrentClass() {
    return Class;
}

public void setClass(String class1) {
    Class = class1;
}

public String getUserName() {
    return UserName;
}

public void setUserName(String userName) {
    UserName = userName;
}

public String getPassword() {
    return Password;
}

public void setPassword(String password) {
    Password = password;
}

public String getDOB() {
    return DOB;
}

public void setDOB(String dOB) {
    DOB = dOB;
}

public String getMobileNo() {
    return MobileNo;
}

public void setMobileNo(String mobileNo) {
    MobileNo = mobileNo;
}

public String getRelation() {
    return Relation;
}

public void setRelation(String relation) {
    Relation = relation;
}

@Override
public String toString() {

    return "\nRegistration No\t: " + getID() + "\n\nName\t\t\t\t\t\t\t: " + getName() + "\n\nFather Name\t\t\t: " + getFName() + "\n\nClass\t\t\t\t\t\t\t: "
            + getCurrentClass() + "\n\nCity\t\t\t\t\t\t\t\t: Islamabad" + "\n\nAdress\t\t\t\t\t\t: Islamabad";

}

}
public类settrgetter实现可序列化{
int-ID;
字符串名称=”;
字符串FName=“”;
字符串类=”;
字符串UserName=“”;
字符串密码=”;
字符串DOB=“”;
连环暴徒