0

我问的问题可能已经被问过了,但我被卡住了。我想将数据从EditText一个活动传递到ListView另一个活动我该怎么做。我使用了意图putExtra,但我无法实现 get 函数,所以任何人都可以告诉我如何实现 get 函数ListView

private static class ListViewAdapter extends BaseAdapter{

    private LayoutInflater Linflate;
    private Object convertView;

    public ListViewAdapter(Context context)
    {
        Linflate=LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return ListViewContent.size();
    }

    @Override
    public Object getItem(int arg0) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public View getView(int position, View v, ViewGroup arg2) {
        final ListContent holder;


        if (v== null) {
            v = Linflate.inflate(R.layout.listviewinflator, null);

            holder = new ListContent();
            holder.text = (TextView) v.findViewById(R.id.TextView01);
           holder.text.setCompoundDrawables(v.getResources().getDrawable(R.drawable.ic_launcher), null, null, null);

            v.setTag(holder);

        } else {

            holder = (ListContent)v.getTag();
        }


        holder.text.setText(ListViewContent.get(position));


              return v;
    }

    static class ListContent {
        TextView text;


}



}
private static final ArrayList<String> ListViewContent = new ArrayList<String>();

}

在这个我想设置get方法。

4

1 回答 1

1

制作一个模型类并序列化它。传递该类的对象

 putSerializable("object", object);

在第二类中获取对象 -

Bundle bundel = getIntent().getExtras();             
object = (myClass) bundel.get("object");  
于 2013-08-10T20:16:19.033 回答