Note that there are some explanatory texts on larger screens.

plurals
  1. POsave editbox values in the custom listview
    text
    copied!<p>am having a two editbox. the values enter in that has to placed in the custom listview its working fine for this...</p> <p>but i want to save this values in the list view permanently.so that if the phones switches off and again run the app then the values have to be saved ..like phone contact number and name have to be saved.. here am ataching the code</p> <pre><code>public class Editcard extends Activity{ EditText cardname,cardDescription ; MyApplication app; @SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.editcredit); app = ((MyApplication) getApplicationContext()); cardname =(EditText)findViewById(R.id.cardash); cardDescription =(EditText)findViewById(R.id.editdescription); Button save =(Button)findViewById(R.id.save); save.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub app.carddata =cardname.getText().toString(); System.out.println("Gotcardname"+app.carddata); app.descriptiondata =cardDescription.getText().toString(); System.out.println("gotDescription"+app.descriptiondata); app.arryList.add(app.carddata); app.arryList1.add(app.descriptiondata); Intent saveIntent =new Intent(Editcard.this,Newcard.class); startActivity(saveIntent); } }); } } public class MyApplication extends Application{ ArrayList&lt;String&gt; arryList = new ArrayList&lt;String&gt;(); ArrayList&lt;String&gt; arryList1 = new ArrayList&lt;String&gt;(); String carddata,descriptiondata,=null; } public class Newcard extends Activity { MyAdapter adapter; ListView listView; LayoutInflater lay; MyApplication app; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.newcard); app = ((MyApplication) getApplicationContext()); TextView newcard =(TextView)findViewById(R.id.newcard); newcard.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub Intent card = new Intent(Newcard.this,Editcreditcard.class); startActivity(card); } }); listView = (ListView) findViewById(R.id.cardlist); adapter =new MyAdapter(this, app.arryList,app.arryList1); listView.setAdapter(adapter); } public class MyAdapter extends BaseAdapter { Context context = null; ArrayList&lt;String&gt; items= null; ArrayList&lt;String&gt; items1= null; public MyAdapter(Newcard newcard, ArrayList&lt;String&gt; items, ArrayList&lt;String&gt; items1) { // TODO Auto-generated constructor stub this.items = items; this.items1 = items1; } @Override public int getCount() { // TODO Auto-generated method stub return items.size(); } @Override public Object getItem(int position) { // TODO Auto-generated method stub return items; //return items.get(position); } @Override public long getItemId(int position) { // TODO Auto-generated method stub return position; } @Override public View getView(final int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub View layout = null; TextView produ = null; TextView desc = null; if (convertView == null) { lay = LayoutInflater.from(getApplicationContext()); layout = lay.inflate(R.layout.customlist, null); } else { layout = convertView; } produ = (TextView) layout.findViewById(R.id.card); produ.setText("" +app.arryList.get(position)); desc= (TextView) layout.findViewById(R.id.descrip); desc.setText("" +app.arryList1.get(position)); return layout; } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload