コード内の "execute"という単語が、シンボルメソッドexecute(String)を見つけることができないというエラーを引き起こしています。誰もエラーplsを解決するのを助けることができますか?おかげシンボルメソッドが見つかりません。execute(String)-Android Studio
public void onClickGetWeather(View v) {
EditText editText = (EditText) findViewById(R.id.editTextCountry);
String location = editText.getText().toString();
weather_fragment task = new weather_fragment();
try {
double temp = task.execute(location).get();
TextView tv = (TextView) findViewById(R.id.textView);
tv.setText("Temperature: " + temp);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
weather_fragmentコード:
public class WeatherAsyncTask extends AsyncTask<String, Void, Double> {
@Override
protected Double doInBackground(String... params) {
String data = ((new WeatherHttpClient()).getWeatherData(params[0]));
double temp = 0.0f;
try {
temp = JSONWeatherParser.getWeather(data);
} catch (JSONException e) {
e.printStackTrace();
}
return temp;
}
}
は何ですか:だからあなたは本当にあなたがこのようなものが必要になります
weather_fragment
のインスタンスを通して、あなたのasynctaskを開始したい場合はweather_fragment? –
weather_fragmentクラスでexecute(String)というメソッドがありますか? –
@AdnanIsajbegovic weather_fragmentは、非同期タスクを実行するクラスです。これはフラグメントです – user3569503