我有以下代码:
public class MainActivity extends SherlockFragmentActivity implements View.OnClickListener, FragmentA.SomeListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String helloWorld = getResources().getString(R.string.hello_world);
new YqlVplanParser(){ // A AsyncTask
@Override
protected void onPostExecute(String jsonString) {
JsonArray result = JsonArray.readFrom(jsonString);
result.toString();
Toast toast = Toast.makeText(/*HERE I NEED THE ACTIVITY*/, "Nachricht", Toast.LENGTH_LONG);
toast.show();
}
}.execute("query");
}
}
所以通常我会写this
where /*HERE I NEED THE ACTIVITY*/
stand,但我现在如何访问活动?这将引用我的 AsyncTask。