I have defined a ListView, tha gets the data from a service, it has an empty view too:
public class MyActivity extends Activity {
MyObject myObject;
ListView myListView;
MyAdapter myAdapter;
ArrayList<MyListElement> myElements;
Handler h = new Handler(){
public void handleMessage (Message msg){
if(msg.what == 0){
init((ArrayList<MyListElement> ))
}
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_layout);
myListView = (ListView) findViewById(R.id.my_listview);
myObject = (myObject) getIntent().getExtras().get("myObj");
setTitle(getString(R.string.title_activity_chat) + myObject.getDisplayedName());
myElements = new ArrayList<MyListElement>();
LayoutInflater inflater = getLayoutInflater();
myAdapter = new MyAdapter(this, this, R.layout.my_activity, myElements);
myListView.setEmptyView(findViewById(R.id.text1));
myListView.setAdapter(myAdapter);
Intent i = new Intent(MyActivity.this, MyService.class);
...
startService(i);
}
protected void init(List<MyListElement> pHistory) {
myAdapter.addAll(pHistory);
myAdapter.notifyDataSetChanged()
}
...
}
and I have an own ArrayAdapter (MyAdapter).
My problem is, when I start the activity and call the service after I get back the data to init(...) the UI refreshes itself with black flash.
Did somebody met this problem?