1

I have a custom Dialog class outside the subclass that implements the ArrayAdapter is there a way i can call the notifyDataSetChanged() from another class or an inflated view ?

//This is a Subclass
public class myClass extend ArrayAdapter{


   myDialog.showPopDialog();

}


// another class
public class myDialog implements onClickListener{

  public void showPopDialog(){
    Button mybutton = (Button) findViewbyId(R.id.mybutton);
    mybutton.setOnClickListener(this)
   }

    @Override
    public void onClick(View v) {

        // I want to call notifyDataSetChanged() from here
   }
}
DevfaR
  • 1,586
  • 1
  • 9
  • 19

2 Answers2

1

Hope This will help u

In Your **Actitvity** Class :

PassengerListView myAdapter;


//From where u have to call u r notifyDataSetChanged

myAdapter = new PassengerListView(MainActivity.this, allValues);
listView.setAdapter(myAdapter);
myAdapter.notifyDataSetChanged();
Developer
  • 6,292
  • 19
  • 55
  • 115
0

Because the notifyDataSetChanged() is a public method ,so u just need to hold the ref of the adapter u need to invoke this method.
To hold the ref of the object u want ,,,,that's a lot of ways,such as pass the ref by a method (constructer?)in your dialog class,singleton,publuic static ,etc.
The view is the same.

bixiaopeng
  • 383
  • 2
  • 11