android - RunOnUiThread in static method -
how can use runonuithread in static method within activity accessed class ? in mainactivity have method update listview values class utildoc.cs. error:
error cs0120: object reference required non-static field, method, or property 'android.app.activity.runonuithread(system.action)' (cs0120) (myproject)
mainactivity.cs:
public static void updatevalue(string value) { runonuithread(() => { //updatelistview }); } utildoc.cs
public void sendvaluelistview() { string value = getvalue(); mainactivity.updatevalue(value); }
the short answer can't.
instead (but shouldn't) make updatevalue(string value) non-static method , provide utildoc reference mainactivity can call updatevalue.
the better solution create adapter listview , tell update data.
for more information on listview , adapters: http://developer.xamarin.com/guides/android/user_interface/working_with_listviews_and_adapters/
Comments
Post a Comment