Getting the updated array of data from a ListView/Adapter

by Chris Stewart » Wed, 11 Aug 2010 02:45:49 GMT


Sponsored Links
 I must be missing something simple here.  I've searched around but don't
think my search query is touching on the right topics to yield results.
 Anyhow, what I'm after is running through the array of data I bind to a
ListView after a "Submit" button has been clicked.  Here's the sample code
I've found and have hacked up to simplify what I'm after:

private Button btnSubmit;
private List<Map<String,?>> security;
 private SeparatedListAdapter adapter;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        btnSubmit = (Button)this.findViewById(R.id.btnSubmit);
        btnSubmit.setOnClickListener(new OnClickListener()
        {
         @Override
                public void onClick(View v)
         {
         blah();
         }
        });

        security = new LinkedList<Map<String,?>>();
 security.add(createItem("Remember passwords", "Save usernames and passwords
for Web sites", true));
security.add(createItem("Clear passwords", "Save usernames and passwords for
Web sites", false));
 security.add(createItem("Show security warnings", "Show warning if there is
a problem with a site's security", false));

// create our list and custom adapter
adapter = new SeparatedListAdapter(this);
 adapter.addSection("Security", new SimpleAdapter(
this, security, R.layout.list_complex,
 new String[] { ITEM_TITLE, ITEM_CAPTION, ITEM_CP },
new int[] { R.id.list_complex_title, R.id.list_complex_caption,
R.id.list_complex_cb }
 )
);
 ListView list = (ListView)this.findViewById(R.id.lvList);
list.setAdapter(adapter);
    }

    private void blah()
    {
ListView list = (ListView)this.findViewById(R.id.lvList);
Object obj = list.getItemAtPosition(0);
    }

Regards,
Chris Stewart

Fantasy 
Football< http://chriswstewart.com/android-applications/fantasy-football/> ;-
Android app for fantasy football fanatics and MFL owners
Social Updater< http://chriswstewart.com/android-applications/social-updater/> ;-
An easy way to send your status blast to multiple social networks

--



Getting the updated array of data from a ListView/Adapter

by Kumar Bibek » Wed, 11 Aug 2010 04:27:08 GMT


 Write a method in your adapter that will return all the data.

-Kumar Bibek
 http://techdroid.kbeanie.com 




--


Sponsored Links


Getting the updated array of data from a ListView/Adapter

by Chris Stewart » Wed, 11 Aug 2010 04:44:48 GMT


  was able to get this to work.  Now I'm facing a different issue with the
list recycling and reloading the original data. Anyway, he's the "blah"
method from above that works:

private void blah()
{
int count = adapter.getCount();

ListView lv = (ListView)this.findViewById(R.id.lvList);
//int listItemCount = lv.getChildCount();
for( int i=0;i<count;i++ ) {
View v = (View)lv.getChildAt(i);

if (v != null)
{
CheckBox cbox = (CheckBox) v.findViewById(R.id.list_complex_cb);

if (cbox != null)
{
if (cbox.isChecked())
{
String title =
((TextView)((View)lv.getChildAt(i)).findViewById(R.id.list_complex_title)).getText().toString();
System.out.println("Blah");
}
}
}
}
}
Regards,
Chris Stewart

Fantasy
Football<http://chriswstewart.com/android-applications/fantasy-football/>-
Android app for fantasy football fanatics and MFL owners
Social Updater<http://chriswstewart.com/android-applications/social-updater/>-
An easy way to send your status blast to multiple social networks



On Tue, Aug 10, 2010 at 4:26 PM, Kumar Bibek <coomar....@gmail.com> wrote:

>



Other Threads

1. What happens to android.media.AudioSystem?

What is the status of android.media.AudioSystem? It is still in the
0.9 SDK, and its setVolume methods still compile (but
AudioSystem.stayAwake does not) , yet AudioSystem is not in the
current online documentation. Is it going to be deprecated or what?

Thanks.
--~--~---------~--~----~------------~-------~--~----~

2. Error when loading app to 0.9 beta SDK

I ported my app, did a clean build and when trying to deploy it to the
emulator I get the following error:

1882 KB/s (0 bytes in 2048642.001s)
        pkg: /data/local/tmp/AndroCom.apk
Failure [-11]

adb logcat output:

D/PackageParser(   54): Scanning package: /data/app/vmdl38741.tmp
D/dalvikvm(   54): GC freed 4942 objects / 310576 bytes in 55ms
D/dalvikvm(   54): GC freed 3353 objects / 354784 bytes in 52ms
D/dalvikvm(   54): GC freed 6596 objects / 290648 bytes in 57ms
D/dalvikvm(   54): GC freed 20120 objects / 868592 bytes in 86ms
D/dalvikvm(   54): GC freed 20197 objects / 732088 bytes in 82ms
D/dalvikvm(   54): GC freed 20071 objects / 728032 bytes in 96ms
D/PackageManager(   54): Scanning package com.android.commandro
I/PackageManager(   54): /data/app/vmdl38741.tmp changed; unpacking
I/dalvikvm(   27): Opening files: input='/data/app/vmdl38741.tmp'
cache='/data/d
alvik-cache/[EMAIL PROTECTED]@[EMAIL PROTECTED]'
D/dalvikvm(   27): DexInv: --- BEGIN 'vmdl38741.tmp' (bootstrap=0) ---
D/dalvikvm(   27): DexInv: waiting for verify+opt, pid=209
D/dalvikvm(  209): Unable to resolve superclass of Lcom/android/
commandro/activi
ties/AddLocationActivity$LocationActivityOverlay; (885)
D/dalvikvm(  209): Link of class 'Lcom/android/commandro/activities/
AddLocationA
ctivity$LocationActivityOverlay;' failed

I get tons of other "link of class blah-blah" failed errors - merely
for every internal class of the application...

What's wrong - we're not allowed to have internal classes anymore or
what?
--~--~---------~--~----~------------~-------~--~----~

3. new sdk

4. PixelCalculator compile issues

5. No bluetooth support ?!?!?!

6. How to access java.lang.instrument ??

7. How to play Video/Audio Streaming Binary files on H.264 ?