Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid internal passing of data from ListView to activity asynchronously
    primarykey
    data
    text
    <p>I'm trying to learn how list item choices can be passed within the same activity in an Android application. Below, I've got a simple page layout that creates a ListView which is populated by a static string array. I have three other static string arrays listed below that. When the page first loads, it loads up the first array into the ListView. Alot of the code on this page I've cobbled together by reading articles on Android here on stackoverflow, so if I'm doing something dumb, I want to hear about it. My goal is ultimately to have these static string arrays actually populated from an inflated xml file that is synced to the app, but first things first. I'm trying to build my basics first.</p> <p>So I have a listener set on the item click for the ListView. What I need help with is, how do I capture what item they clicked on, and then recreate the activity with the new string array loaded into it? I saw one example which I emulated and it made the app look like it was actually changing pages everytime. Considering the screen will have some static elements on it (a menu bar), I'd like it to refresh itself independent of the overall layout (I guess the best way to describe it in web terminology would be asynchronously, like with AJAX or jQuery).</p> <p>The order of events is TEST_1 is the root with one choice. Click on the choice and it loads up TEST_2. If item 1 on TEST_2 is chosen, load TEST_3a, and vice versa with 2, TEST_3b.</p> <p>Hopefully this makes sense... let me know if I can elaborate further.</p> <p>public class MyLayout extends ListActivity {</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new ArrayAdapter&lt;String&gt;(this, R.layout.listlayout, TEST_1)); ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { //What do I do here? } }); } static final String[] TEST_1 = new String[] { "Members" }; static final String[] TEST_2 = new String[] { "Joe A. Member", "Paula B. User" }; static final String[] TEST_3a = new String[] { "Personal", "Medical", "Financial" }; static final String[] TEST_3b = new String[] { "Personal", "Medical", "Financial" }; </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    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