Hi...
I need help regarding refresh ma list control in android i m using the
following sdk "android-sdk-windows-1.0_r1".
I have extended CustomList from the BaseAdapter and then there is
another class which is extended from the CustomList called LeagueList
is the ActualList whose data i need to refresh when change event
occur.
Following is the code for the CustomList and LeagueList Class.
/*CustomList*/
import java.util.ArrayList;
import android.content.Context;
import android.database.DataSetObserver;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
public class CustomList extends BaseAdapter {
protected LayoutInflater mInflater;
protected Context ctx;
//private Bitmap mIcon1;
//private Bitmap mIcon2;
private static final String[] DATA = null;
public CustomList()
{
}
public CustomList(Context context) {
this.ctx=context;
mInflater = LayoutInflater.from(context);
}
public int getCount() {
return DATA.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
// Make a view to hold each row.
public View getView(int position, View convertView, ViewGroup
parent) {
View v = convertView;
return v;
}
}
/*************************************LeagueList***********/
import java.util.Observer;
import tuvista.observer.TuVistaObserver;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class LeagueList extends CustomList implements TuVistaObserver{
private String[] DATA = {
"In Progress","Team 1" ,"Team 2", "Team 3","Team
4","Completed","Team 5","Team 6","Team 7","Team 8"
};
private Main mainScreenRef=null;
public LeagueList(Context context)
{
//this.ctx=context;
//mInflater = LayoutInflater.from(context);
super(context);
mainScreenRef=(Main)context;
}
public int getCount() {
return DATA.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
// Make a view to hold each row.
public View getView(int position, View convertView, ViewGroup
parent) {
View v = convertView;
TextView tt=null;
String content="";
try
{
content = DATA[position];
// LayoutInflater vi = (LayoutInflater)
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if(content.equals("In Progress"))
{
v = mInflater.inflate(R.layout.seperator,
null);
tt = (TextView)
v.findViewById(R.id.seperatorText);
}else
if(content.equals("Completed"))
{
v = mInflater.inflate(R.layout.seperator,
null);
tt = (TextView)
v.findViewById(R.id.seperatorText);
}
else
{
v =
mInflater.inflate(R.layout.leaguelistitem, null);
tt = (TextView)
v.findViewById(R.id.leagueTitle);
ImageView thumb1 = (ImageView)
v.findViewById
(R.id.leagueThumb);
if (thumb1 != null)
thumb1.setImageResource
(R.drawable.league1);
}
tt.setText(content);
}catch (Exception e) {
e.printStackTrace();
Toast.makeText(ctx, "Exception
..."+e,Toast.LENGTH_LONG).show
();
}
return v;
}
public void handleEvent()
{
System.out.println("Handle Event of League List.");
//System.out.println("");
if(DATA[0].equals("In Progress"))
{
String[] NEWDATA = {"Completed","Team 5","Team
6","Team 7","Team
8" ,"In Progress","Team 1" ,"Team 2", "Team 3","Team 4"};
this.DATA=NEWDATA;
}else
{
String[] NEWDATA = {"In Progress","Team 1"
,"Team 2", "Team
3","Team 4","Completed","Team 5","Team 6","Team 7","Team 8"};
this.DATA=NEWDATA;
}
repaint();
}
}
Observer Design patteren implemented handleEvent() is called when any
change happened at server....
Please help me in that ASAP...
Regards,
Salman Khursheed
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en