0
調用一個方法我想打電話從的AsyncTask)稱爲getHoroscope(一個方法,從另一個類,我想這安卓:從的AsyncTask
String sentence, signo="geminis";
sentence = new ExtendedActivity.Parse().getHoroscope("daily",signo);
,但我得到的錯誤「ExtendedActivity is not an enclosing class
」。 你能幫我嗎?
我ExtendedActivity:
public class ExtendedActivity extends BaseActivity {
(...)
public class Parse extends AsyncTask<String, Void, String> {
private final ProgressDialog dialog = new ProgressDialog(ExtendedActivity.this);
@Override
public String doInBackground(String... params) {
String option, type, dat, site="", description="", s="";;
//get the user option
Bundle extras = getIntent().getExtras();
option = extras.getString("OPTION");
type = extras.getString("TYPE");
description = getHoroscope(type, option);
return description;
}
public String getHoroscope(String type, String option){
String description="", site;
(...)
}
}
您正在創建ExtendedActivity的對象並嘗試從Parse()類靜態訪問一個方法。要麼聲明Parse和getHoroscope是靜態的,要麼創建一個Parse對象 –
可能重複[不是封閉類Java](http://stackoverflow.com/questions/20252727/is-not-an-enclosing-class-java) –
你在哪裏調用'AsyncTask.execute'? –