Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create a clickable Listview and go to new page where the user can add items within the list
    primarykey
    data
    text
    <p>I would like some guidance on how to create a clickable Listview and go to new page where the user can add items within the list as I am creating a To Do List, and I want the user to be able to create multiple lists, and then tap the list, and enter multiple items within that very list.</p> <p>Thanks. </p> <p><strong>UPDATE - Added .java code for reference. This may explain what I have implemented thus far better than the text above.</strong> </p> <pre><code>public class ActionBarMenuDemoActivity extends SherlockListActivity { private static final String[] items = { }; private ArrayList&lt;String&gt; words = null; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); initAdapter(); registerForContextMenu(getListView()); } @Override public boolean onCreateOptionsMenu(Menu menu) { new MenuInflater(this).inflate(R.menu.option, menu); EditText add = null; if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB) { View v = menu.findItem(R.id.add).getActionView(); if (v != null) { add = (EditText) v.findViewById(R.id.title); } } if (add != null) { add.setOnEditorActionListener(onSearch); } return (super.onCreateOptionsMenu(menu)); } public void onCreateContextMenu(Menu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { new MenuInflater(this).inflate(R.menu.context, menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch(item.getItemId()) { case R.id.add: add(); break; case R.id.preferences: startActivity(new Intent(getApplicationContext(),SettingsActivity.class)); break; } return (super.onOptionsItemSelected(item)); } @Override @SuppressWarnings("unchecked") public boolean onContextItemSelected(android.view.MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); ArrayAdapter&lt;String&gt; adapter = (ArrayAdapter&lt;String&gt;) getListAdapter(); int itemId = item.getItemId(); if (itemId == R.id.cap) { String input = words.get(info.position); input = input.toUpperCase(); adapter.remove(words.get(info.position)); adapter.insert(input, info.position); return (true); } return (super.onContextItemSelected(item)); } private void initAdapter() { words = new ArrayList&lt;String&gt;(); for (String s : items) { words.add(s); } setListAdapter(new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, words)); } private void add() { final View addView = getLayoutInflater().inflate(R.layout.add, null); new AlertDialog.Builder(this).setTitle("Add a List").setView(addView) .setPositiveButton("Create", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { addWord((TextView) addView.findViewById(R.id.title)); } }).setNegativeButton("Cancel", null).show(); } @SuppressWarnings("unchecked") private void addWord(TextView title) { ArrayAdapter&lt;String&gt; adapter = (ArrayAdapter&lt;String&gt;) getListAdapter(); adapter.add(title.getText().toString()); Toast.makeText(ActionBarMenuDemoActivity.this, title.getText().toString() + " Created", Toast.LENGTH_LONG) .show(); title.setText(""); } private TextView.OnEditorActionListener onSearch = new TextView.OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (event == null || event.getAction() == KeyEvent.ACTION_UP) { addWord(v); InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); } return (true); } }; } </code></pre> <p>Some of this code will be removed, as I used a tutorial as my starting point. </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.
    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