top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to Save to an Array and display array in listview on another activity ?

+1 vote
348 views

I use this code to save the contents of a textbox to an array, i want display this array in a list view on another activity.
any idea about this? thanks.

txt = (TextView)findViewById(R.id.name);
show = (ListView)findViewById(R.id.mygardenlist);
add = (Button)findViewById(R.id.btnAdd);
add.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
    String getInput = txt.getText().toString();
    if(addArray.contains(getInput)) {
        Toast.makeText((getBaseContext()), "Plant Already Added", Toast.LENGTH_LONG).show();
    }
    else {
        addArray.add(getInput);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(SingleItemView.this, android.R.layout.simple_list_item_1, addArray);
        show.setAdapter(adapter);
        ((TextView)findViewById(R.id.name)).setText(" ");
    }
}
});
posted Feb 9, 2017 by Samira Sharma

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

...