0

If i type "Hello" in my edittext in activity 1 it will add "Hello" to the listview in activity 2 as the first entry ( which has no error ). Also, if I type "Apple" as my second entry I will change the first entry of "Hello" to "Apple" and add the new 2nd entry "Apple"... causing both entries to become "Apple" and "Apple"... any thoughts?

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_argue_list);

        ListView txtlist = (ListView)findViewById(android.R.id.list);


        Bundle bun = getIntent().getExtras();
         Lrg = bun.getString("Jenny");
         Med = bun.getString("Forest");
         Med2 = bun.getString("Gump");

            KoreyzAdapter add = new KoreyzAdapter();
            txtlist.setAdapter(add);
            list.add(0, Lrg);
            add.notifyDataSetChanged();
            setListAdapter(add);
    }
    class KoreyzAdapter extends ArrayAdapter<String>{

          public KoreyzAdapter() {
              super(ArgueListActivity.this, android.R.layout.simple_list_item_1, list);
        }
          class ViewHolder{
              TextView who;
              TextView sex;
              TextView cat;
              ImageView pic;

              ViewHolder(View v){
                  who = (TextView) v.findViewById(R.id.inputLrgtxt);
                  sex = (TextView) v.findViewById(R.id.whoMedtxt);
                  cat = (TextView) v.findViewById(R.id.stupidMedtxt);
                  pic = (ImageView)v.findViewById(R.id.sexpic);
              }

          }
                    public View getView(int position, View convertView, ViewGroup parent) {
                        View row = convertView;
                        ViewHolder holder = null;
                        if(row == null){

                             LayoutInflater inflator = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                            row = inflator.inflate(R.layout.list_item, parent, false);
                            holder = new ViewHolder(row);
                            row.setTag(holder);

                        }else{
                            holder = (ViewHolder)row.getTag();
                        }

                            holder.who.setText(Lrg);
                            holder.sex.setText(Med);
                            holder.cat.setText(Med2);

                            holder.pic.setImageResource(R.drawable.maleandfemale);

                            return row;
                        }
2
Contributors
2
Replies
56
Views
4 Years
Discussion Span
Last Post by CitySlickaMr
0
Intent i = new Intent(this, ArgueListActivity.class);
         Bundle bun = new Bundle();
         bun.putString("Jenny", whatedit.getText().toString());
         bun.putString("Forest", sex.getSelectedItem().toString());
         bun.putString("Gump", cat.getSelectedItem().toString());
         i.putExtras(bun);
         whatedit.setText("");
         startActivity(i);
        }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.