Saya mencoba mengonversi Aktivitas menjadi fragmen. Tanda kesalahan aktif runOnUiThread
. di masa lalu:
GoogleActivityV2 diturunkan dari Aktivitas. runOnUiThread di kelas ExecuteTask. class ExecuteTask bertingkat pada aktivitas.
(Jalankan ok) sekarang:
GoogleActivityV2 diturunkan dari Fragment. runOnUiThread di kelas ExecuteTask. class ExecuteTask bertingkat pada aktivitas. (Kesalahan saat runOnUiThread)
ini kode saya
public class GoogleActivityV2 extends SherlockMapFragment implements OnMapClickListener , OnMapLongClickListener , OnCameraChangeListener , TextWatcher {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
View rootView = inflater.inflate(R.layout.activity_googlev2, container, false);
Init();
adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line);
textView = (AutoCompleteTextView) getView().findViewById(R.id.autoCompleteTextView1);
return rootView;
}
public void onCameraChange(CameraPosition arg0){
// TODO Auto-generated method stub
}
public void onMapLongClick(LatLng arg0){
llLoc = arg0;
stCommand = "onTouchEvent";
lp = new ExecuteTask();
lp.execute();
}
public void onMapClick(LatLng arg0){
// TODO Auto-generated method stub
}
class ExecuteTask extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute(){
super.onPreExecute();
if(stCommand.compareTo("AutoCompleteTextView") != 0) {
pDialog = new ProgressDialog(getActivity());
pDialog.setMessage(Html.fromHtml("<b>Search</b><br/>Loading ..."));
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
}
}
protected String doInBackground(String ... args){
do something
return null;
}
@Override
protected void onPostExecute(String file_url){
if(stCommand.compareTo("AutoCompleteTextView") != 0) pDialog.dismiss();
runOnUiThread(new Runnable() {
public void run(){
do something
}
});
}
}
public void afterTextChanged(Editable s){
// TODO Auto-generated method stub
}
public void beforeTextChanged(CharSequence s, int start, int count, int after){
// TODO Auto-generated method stub
}
public void onTextChanged(CharSequence s, int start, int before, int count){
// TODO Auto-generated method stub
}
}
kesalahannya mengatakan:
bagaimana cara memperbaiki kesalahan ini?