Android 애플리케이션을 개발 중이며 Eclipse를 IDE로 사용하고 데이터베이스가 MySQL입니다. 내가 따라야 할 문제가있다. AsynTask를 통해 데이터베이스에서 데이터를 가져 오려고하면 아래에 오류가 있습니다.
android.view.ViewRootImpl$CalledFromWrongThreadException:
Only the original thread that created a view hierarchy
can touch its views
활동 :
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
asyn=new MyAsyncTask();
tvtexto=(TextView)findViewById(R.id.tvtextoMa);
context = getApplicationContext();
eventos = new ArrayList<Eventos>();
eventosAdapter = new EventosAdapter(context, R.layout.filae, eventos);
eventos=new ArrayList<Eventos>();
asyn.execute();
listView = (ListView)findViewById(R.id.ListView01Ma);
}
AsyncTask를 : 배경 스레드에서
public class MyAsyncTask extends AsyncTask<Void, Void, Void>
{
@Override
protected Void doInBackground(Void... arg0)
{
eventos=(ArrayList<Eventos>) BDEventos.getDatosEventos();
for(Eventos n:eventos){
eventosAdapter.add(n);
}
eventosAdapter.notifyDataSetChanged();
listView.setAdapter(eventosAdapter);
return null;
}
}
가되어야한다. –onPostExecute
에가능한 중복 [CalledFromWrongThreadException] (http://stackoverflow.com/questions/3413544/calledfromwrongthreadexception) –