GetView + Intent 参数对象错误
GetView + Intent Param Object Error
我现在有这个问题:java.lang.RuntimeException: Parcelable 遇到 IOException 写入可序列化对象.. Class Filho 实现可序列化。如何解决?
public View getView(int position, View view, ViewGroup parent)
{
final Filho filhoPosition = this.listaFilhos.get(position);
view = LayoutInflater.from(this.context).inflate(R.layout.lista_filho,null);
TextView textViewNomeFilho = (TextView) view.findViewById(R.id.textViewNomeFilho);
TextView textViewTelefoneFilho = (TextView) view.findViewById(R.id.textViewTelefoneFilho);
ImageView imageViewFotoFilho = (ImageView) view.findViewById(R.id.imageViewFotoFilho);
textViewNomeFilho.setText(filhoPosition.getNome());
textViewTelefoneFilho.setText(filhoPosition.getTelefone());
imageViewFotoFilho.setImageBitmap(filhoPosition.getFoto());
final ImageButton imageButtonConfigFilho = (ImageButton) view.findViewById(R.id.imageButtonConfigFilho);
imageButtonConfigFilho.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
filho = new Filho(filhoPosition.getIdFilho(),filhoPosition.getNome(),filhoPosition.getTelefone(),filhoPosition.getFoto(),filhoPosition.getLoginConfig());
Intent it = new Intent(context, CadastrarFilhoActivity.class);
it.putExtra("filho",filho);
context.startActivity(it);
}
});
return view;
}
使Filho
class实现Serializable
。这是一个常见问题
即转到 Filho
class 并实施 Serializable
public class Filho class implements Serializable
编辑
像这样使用你正在使用的意图putExtra()
Intent it = new Intent(context, CadastrarFilhoActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable("filho",filho);
it.putExtras(bundle);
并在 CadastrarFilhoActivity.class
中完成
Intent intent = this.getIntent();
Bundle bundle = intent.getExtras();
Filho filho=(Filho)bundle.getSerializable("filho");
如果我将 4 参数作为位图像 null 一样工作,由于某种原因位图字段会出现此问题,因为我不是 java 和 android 的新手而且我有不知道怎么解决
it.putExtra("filho",new Filho(filhoPosition.getIdFilho(),filhoPosition.getNome(),filhoPosition.getTelefone(),filhoPosition.getFoto(),filhoPosition.getLoginConfig()));
我现在有这个问题:java.lang.RuntimeException: Parcelable 遇到 IOException 写入可序列化对象.. Class Filho 实现可序列化。如何解决?
public View getView(int position, View view, ViewGroup parent)
{
final Filho filhoPosition = this.listaFilhos.get(position);
view = LayoutInflater.from(this.context).inflate(R.layout.lista_filho,null);
TextView textViewNomeFilho = (TextView) view.findViewById(R.id.textViewNomeFilho);
TextView textViewTelefoneFilho = (TextView) view.findViewById(R.id.textViewTelefoneFilho);
ImageView imageViewFotoFilho = (ImageView) view.findViewById(R.id.imageViewFotoFilho);
textViewNomeFilho.setText(filhoPosition.getNome());
textViewTelefoneFilho.setText(filhoPosition.getTelefone());
imageViewFotoFilho.setImageBitmap(filhoPosition.getFoto());
final ImageButton imageButtonConfigFilho = (ImageButton) view.findViewById(R.id.imageButtonConfigFilho);
imageButtonConfigFilho.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
filho = new Filho(filhoPosition.getIdFilho(),filhoPosition.getNome(),filhoPosition.getTelefone(),filhoPosition.getFoto(),filhoPosition.getLoginConfig());
Intent it = new Intent(context, CadastrarFilhoActivity.class);
it.putExtra("filho",filho);
context.startActivity(it);
}
});
return view;
}
使Filho
class实现Serializable
。这是一个常见问题
即转到 Filho
class 并实施 Serializable
public class Filho class implements Serializable
编辑
像这样使用你正在使用的意图putExtra()
Intent it = new Intent(context, CadastrarFilhoActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable("filho",filho);
it.putExtras(bundle);
并在 CadastrarFilhoActivity.class
Intent intent = this.getIntent();
Bundle bundle = intent.getExtras();
Filho filho=(Filho)bundle.getSerializable("filho");
如果我将 4 参数作为位图像 null 一样工作,由于某种原因位图字段会出现此问题,因为我不是 java 和 android 的新手而且我有不知道怎么解决
it.putExtra("filho",new Filho(filhoPosition.getIdFilho(),filhoPosition.getNome(),filhoPosition.getTelefone(),filhoPosition.getFoto(),filhoPosition.getLoginConfig()));