refreshing listview

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

refreshing listview

Postby sabs » Sat Jan 30, 2010 2:01 pm

Hii

I have a list view now i would like to refresh the data means after particular amount of the time, i would like to redraw the entire listview(data) .
(simply saying how to refresh ListView when I add some dynamic data in Android.)

thanks
sabs
sabs
Developer
Developer
 
Posts: 32
Joined: Fri Dec 04, 2009 2:55 pm

Top

Re: refreshing listview

Postby jagtap.jj1 » Sat Jan 30, 2010 2:16 pm

Call the "setListAdapter()" http://developer.android.com/reference/ ... istAdapter)
OR "onContentChanged()" http://developer.android.com/reference/ ... ntChanged()
Whenever data added, deleted, etc from list.
java-android developer
User avatar
jagtap.jj1
Senior Developer
Senior Developer
 
Posts: 124
Joined: Fri Aug 22, 2008 11:52 am
Location: India(Mumbai)

Re: refreshing listview

Postby sabs » Sat Jan 30, 2010 2:31 pm

jagtap.jj1 wrote:Call the "setListAdapter()" http://developer.android.com/reference/ ... istAdapter)
OR "onContentChanged()" http://developer.android.com/reference/ ... ntChanged()
Whenever data added, deleted, etc from list.


Thank u for the quick reply
I have called the setList adapter but not working. if you have done this type of program please post the code

thanks
sabs
sabs
Developer
Developer
 
Posts: 32
Joined: Fri Dec 04, 2009 2:55 pm

Re: refreshing listview

Postby jagtap.jj1 » Sat Jan 30, 2010 2:36 pm

Its good if you post your code snap shot, might be error in adapter, Or calling setListAdapter in different thread than GUI thread(MainThread) i.e. in the sub thread which is not having handler.
java-android developer
User avatar
jagtap.jj1
Senior Developer
Senior Developer
 
Posts: 124
Joined: Fri Aug 22, 2008 11:52 am
Location: India(Mumbai)

Re: refreshing listview

Postby sabs » Mon Feb 01, 2010 2:18 pm

jagtap.jj1 wrote:Its good if you post your code snap shot, might be error in adapter, Or calling setListAdapter in different thread than GUI thread(MainThread) i.e. in the sub thread which is not having handler.


Hi,
I have tried and find the solution for refreshing the list view. Now my another problem is, i have an expandable list view in that collecting some data and displaying, now is it possible to refresh the data in that expandable list view. If any one have the idea please share with me.

thanks
sabs
sabs
Developer
Developer
 
Posts: 32
Joined: Fri Dec 04, 2009 2:55 pm

Sorry, can you help me

Postby batakkeren » Thu Feb 04, 2010 9:09 am

Im a new beginner android developer
now i create android app using eclipse plugins
theres something wrong :

i create listview, in PulsaElektrik.java
when item click i just wanna show/run another class java let say (InputMenu.java)
but always errorrr!!!!!!

here my PulsaElektrik.java

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. package com.pulsa.android;
  3.  
  4.  
  5.  
  6. import android.app.ListActivity;
  7.  
  8. import android.content.Intent;
  9.  
  10. import android.os.Bundle;
  11.  
  12. import android.view.View;
  13.  
  14. import android.widget.AdapterView;
  15.  
  16. import android.widget.ArrayAdapter;
  17.  
  18. import android.widget.ListView;
  19.  
  20. import android.widget.TextView;
  21.  
  22. import android.widget.Toast;
  23.  
  24. import android.widget.AdapterView.OnItemClickListener;
  25.  
  26.  
  27.  
  28. public class PulsaElektrik extends ListActivity implements OnItemClickListener {
  29.  
  30.  
  31.  
  32.         private static final int MY_PULSA = 0;
  33.  
  34.  
  35.  
  36.         @Override
  37.  
  38.         public void onCreate(Bundle savedInstanceState) {
  39.  
  40.                 super.onCreate(savedInstanceState);
  41.  
  42.  
  43.  
  44.                 String[] countries = getResources().getStringArray(
  45.  
  46.                                 R.array.countries_array);
  47.  
  48.                 setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item,
  49.  
  50.                                 countries));
  51.  
  52.  
  53.  
  54.                 ListView lv = getListView();
  55.  
  56.                 lv.setTextFilterEnabled(true);
  57.  
  58.                 lv.setOnItemClickListener(this);
  59.  
  60.         }
  61.  
  62.        
  63.  
  64.        
  65.  
  66.  
  67.  
  68.         @Override
  69.  
  70.         public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  71.  
  72.                 // TODO Auto-generated method stub
  73.  
  74.                 // When clicked, show a toast with the TextView text
  75.  
  76.  
  77.  
  78.                 if (((TextView) view).getText().equals("Bahrain")) {
  79.  
  80.  
  81.  
  82.                         //Toast.makeText(getApplicationContext(), " Please wait... ",
  83.  
  84.                         //              Toast.LENGTH_SHORT).show();
  85.  
  86.  
  87.  
  88.                         Intent intent = new Intent();
  89.  
  90.                         intent.setClass(PulsaElektrik.this, InputMenu.class);
  91.  
  92.                         Bundle bundle = new Bundle();
  93.  
  94.                         //bundle.putInt("Longitude", "");
  95.  
  96.                         //bundle.putInt("Latitude", "");
  97.  
  98.                         intent.putExtras(bundle);
  99.  
  100.                         startActivity(intent);                 
  101.  
  102.  
  103.  
  104.                 } else {
  105.  
  106.  
  107.  
  108.                         Toast.makeText(getApplicationContext(),
  109.  
  110.                                         ((TextView) view).getText(), Toast.LENGTH_SHORT).show();
  111.  
  112.                 }
  113.  
  114.  
  115.  
  116.         }
  117.  
  118.  
  119.  
  120.  
  121.  
  122. }
  123.  
  124.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4



Here my InputMenu.java



Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3.  
  4. package com.pulsa.android;
  5.  
  6.  
  7.  
  8. import android.app.ListActivity;
  9.  
  10. import android.os.Bundle;
  11.  
  12. import android.view.View;
  13.  
  14. import android.widget.Button;
  15.  
  16. import android.widget.CheckBox;
  17.  
  18. import android.widget.EditText;
  19.  
  20.  
  21.  
  22. public class InputMenu extends ListActivity {
  23.  
  24.        
  25.  
  26.         @Override
  27.  
  28.         public void onCreate(Bundle savedInstanceState) {
  29.  
  30.             super.onCreate(savedInstanceState);
  31.  
  32.             setContentView(R.layout.input_menu);
  33.  
  34.        
  35.  
  36.             populateWidgets();
  37.  
  38.        
  39.  
  40.         // setup handler for Ok button
  41.  
  42.         Button btnOk = (Button) findViewById(R.id.btnOk);
  43.  
  44.         btnOk.setOnClickListener(new View.OnClickListener() {
  45.  
  46.            public void onClick(View arg0) {
  47.  
  48.                    persistWidgetData();
  49.  
  50.                    setResult(RESULT_OK);
  51.  
  52.                    finish();
  53.  
  54.            }
  55.  
  56.         });
  57.  
  58.         // setup handler for the Cancel button
  59.  
  60.         Button btnCancel = (Button) findViewById(R.id.btnCancel);
  61.  
  62.         btnCancel.setOnClickListener(new View.OnClickListener() {
  63.  
  64.             public void onClick(View arg0) {
  65.  
  66.                    setResult(RESULT_CANCELED);
  67.  
  68.                    finish();
  69.  
  70.             }
  71.  
  72.          });
  73.  
  74.  
  75.  
  76.         }
  77.  
  78.        
  79.  
  80.         private void populateWidgets(){
  81.  
  82.         // do work here to populate widgets
  83.  
  84.         // checkbox
  85.  
  86.         CheckBox chkExample = (CheckBox) findViewById(R.id.chkExample);
  87.  
  88.         chkExample.setChecked(true);
  89.  
  90.         // edit
  91.  
  92.         EditText editExample = (EditText) findViewById(R.id.editExample);
  93.  
  94.         editExample.setText("some example text");
  95.  
  96.     }
  97.  
  98.  
  99.  
  100.     private void persistWidgetData(){
  101.  
  102.         // do work here to persist values from widgets
  103.  
  104.     }
  105.  
  106. }
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
Parsed in 0.037 seconds, using GeSHi 1.0.8.4



Error show when this one in PulsaElektrik.java:


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3.  
  4. Intent intent = new Intent();
  5.  
  6.                         intent.setClass(PulsaElektrik.this, InputMenu.class);
  7.  
  8.                         Bundle bundle = new Bundle();
  9.  
  10.                         //bundle.putInt("Longitude", "");
  11.  
  12.                         //bundle.putInt("Latitude", "");
  13.  
  14.                         intent.putExtras(bundle);
  15.  
  16.                         startActivity(intent);
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4



Can you help me please....
Im beginner...
Needed your help....
Or can you give me some sample...
ListView project, when onitem click...
Run another activity/class/menu.. whatever...

Thanks alot..
:)

-batakkeren
Im a beginner android developer,
batakkeren
Freshman
Freshman
 
Posts: 7
Joined: Thu Feb 04, 2010 8:56 am
Location: Jakarta

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 13 guests