0
我有以下代碼:如何訪問另一個對象中的Andorid活動?
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");
}
}
所以normaly我會寫this
其中/*HERE I NEED THE ACTIVITY*/
看臺上,但我怎麼能現在訪問活動?這將引用我的AsyncTask。