Note that there are some explanatory texts on larger screens.

plurals
  1. POEdittext only adding first item to arraylist<string>
    primarykey
    data
    text
    <p>I'm at a lose with this one. Trying to take edittext from a list view and put them into an arraylist to use on another activity. </p> <pre><code>public class editpage extends ListActivity { public static String editString; private dbadapter mydbhelper; public static ArrayList&lt;String&gt; editTextList = new ArrayList&lt;String&gt;(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.edit_list); mydbhelper = new dbadapter(this); mydbhelper.open(); fillData(); } public void fillData() { Cursor e = mydbhelper.getUserWord(); startManagingCursor(e); String[] from = new String[] {dbadapter.KEY_USERWORD,}; int[] to = new int[] {R.id.textType,}; SimpleCursorAdapter editadapter = new SimpleCursorAdapter(this, R.layout.edit_row, e, from, to); ListView list = getListView(); View footer = getLayoutInflater().inflate(R.layout.footer_layout, list, false); list.addFooterView(footer); setListAdapter(editadapter); } public void onClick(View footer){ final MediaPlayer editClickSound = MediaPlayer.create(this, R.raw.button50); final EditText editText = (EditText) findViewById(R.id.editText); for (int i = 0; i &lt; getCount(); i++){ editTextList.add(editText.getText().toString()); } editClickSound.start(); startActivity(new Intent("wanted.pro.madlibs.OUTPUT")); }; //can't get my getcount to work dynamically. I want it to be based off how many items are shown in next code showing my cursor but can't get to work atm unless I set statically to prevent errors and move to next activity private int getCount() { // TODO Auto-generated method stub return 10; } Cursor to filter data pulled from database public Cursor getUserWord() { return myDataBase.query(USER_WORD_TABLE, new String[] { KEY_ID, KEY_CATEGORY, KEY_SOURCE, KEY_TITLE, KEY_USERWORD }, KEY_CATEGORY+ "=" + categories.categoryClick + " AND " + KEY_SOURCE+ "=" +source.sourceClick + " AND " + KEY_TITLE+ "=" + title.titleClick, null, null, null, KEY_ID); </code></pre> <p>Cursor to filter data from database to show in listview</p> <pre><code> public Cursor getUserWord() { return myDataBase.query(USER_WORD_TABLE, new String[] { KEY_ID, KEY_CATEGORY, KEY_SOURCE, KEY_TITLE, KEY_USERWORD }, KEY_CATEGORY+ "=" + categories.categoryClick + " AND " + KEY_SOURCE+ "=" +source.sourceClick + " AND " + KEY_TITLE+ "=" + title.titleClick, null, null, null, KEY_ID); } </code></pre> <p>My next activity will be showing the edittext merged with a string from my database. I take this string and replace edit01, edit02 etc with the users input from edittext fields on previous activity</p> <pre><code>public class output extends ListActivity { private dbadapter mydbhelper; @Override public void onCreate(Bundle savedInstantState){ super.onCreate(savedInstantState); setContentView(R.layout.outview); mydbhelper = new dbadapter(this); mydbhelper.open(); fillData(); } private final Runnable mTask = new Runnable(){ public void run(){ TextView textView = (TextView)findViewById(R.id.outputText); String story = textView.getText().toString(); CharSequence modifitedText1 = Replacer.replace(story, "edit01", Html.fromHtml("&lt;font color=\"red\"&gt;"+ editpage.editTextList.get(0) +"&lt;/font&gt;")); CharSequence modifitedText2 = Replacer.replace(modifitedText1, "edit02", Html.fromHtml("&lt;font color=\"red\"&gt;"+ editpage.editTextList.get(1) +"&lt;/font&gt;")); textView.setText(modifitedText2); } }; private final Handler mHandler = new Handler(); private void fillData() { Cursor st = mydbhelper.getStory(); startManagingCursor(st); String[] from = new String[] {dbadapter.KEY_TITLESTORY}; int[] to = new int[] {R.id.outputText}; SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.out_row, st, from, to); setListAdapter(adapter); } @Override protected void onResume() { mydbhelper.open(); mHandler.postDelayed(mTask, 10); super.onResume(); } @Override protected void onPause() { mydbhelper.close(); super.onPause(); } } </code></pre> <p>The furthest I can get this to work is with one item. I will be having anywhere from 4-10 edittexts on the first activity I show here. But no matter what I've tried it will only display the text entered into the first edittext field. In it's current state it will fill edit01 &amp; edit02 in the string from database with what was put in first edittext in previous activity.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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