Click here to Skip to main content
15,895,787 members

getting excception in notifydatachanged listview adaptor

shanalikhan asked:

Open original thread
Hi ,
im getting exception on repopulating data on listview.
following is the code :

Quote:
@Override
public void run() {

// TODO Auto-generated method stub
if(ser.FindClients().interact.get(a).drive!=null){

//Log.e("FILEMANAGERACTIVITY", String.valueOf(ser.FindClients().interact.get(a).drive.size()));
fmd = new FileManagerAdaptor(FileManagerActivity.this, R.layout.activity_item_layout, ser.FindClients().interact.get(a).drive);

lst.setAdapter(fmd);
lst.setOnItemClickListener(new OnItemClickListener() {

@Override
public void onItemClick(AdapterView View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
//Toast.makeText(this, text, duration)
TextView txt = (TextView)arg1.findViewById(R.id.lblName);
Log.e("FILEMANAGERACTIVITY", "Done");
tmp = (String) txt.getText();
itemPosition = arg2;


new Thread(){

@Override
public void run() {
// TODO Auto-generated method stub

ser.FindClients().interact.get(a).ListFiles(tmp, ser.FindClients().interact.get(a).fileType.get(itemPosition));
//while(ser.FindClients().interact.get(a).working!=false);
//fmd = new FileManagerAdaptor(FileManagerActivity.this, R.layout.activity_item_layout, ser.FindClients().interact.get(a).fileNames);
//lst.setAdapter(fmd);
//Log.e("FILEMANAGERACTIVITY", String.valueOf(ser.FindClients().interact.get(a).fileNames.size()));

fmd.Data(ser.FindClients().interact.get(a).fileNames);

fmd.notifyDataSetChanged();


Log.e("FILEMANAGERACTIVITY", "List notified data changed");
//lst.setAdapter(fmd);

}
}.start();


}
});

} else
{
Log.e("FILEMANAGERACTIVITY", "Dives null");
}







while the adaptor class is this :


Quote:
public List<string> data=null;
private Context con = null;
int layoutId=0;

public FileManagerAdaptor(Context context, int textViewResourceId,List<string> data) {

this.data = data;
this.con = context;
this.layoutId = textViewResourceId;
// TODO Auto-generated constructor stub
}



@Override
public int getCount() {
// TODO Auto-generated method stub

//return super.getCount();
return data.size();

}

@Override
public String getItem(int position) {
// TODO Auto-generated method stub
//return super.getItem(position);
return data.get(position);
}
public void Data(ArrayList<string> data)
{
this.data = data;
//notifyDataSetChanged();
}


@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View vi = convertView;

LayoutInflater inf =(LayoutInflater) con.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
vi= inf.inflate(layoutId, parent, false);


Log.e("FILEMANAGERADAPTOR", data.get(position));
TextView tx = (TextView) vi.findViewById(R.id.lblName);
tx.setText(data.get(position));
return vi;
}

@Override
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return arg0;
}

}
Tags: Java, Mobile Apps (Android), ListView

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900