나는 asyntask가 있고 진행 중입니다. 텍스트를 TextView로 설정했는데 정상적으로 작동하지만 텍스트 뷰를 재설정하고 ""(이것은 초기 값입니다), postupdate에서 새로운 findviewbyid (r.id.tvProgreso); textview를 업데이트하지만 텍스트는 동일합니다.Textview는 화면이 회전 한 후 asyntask에서 업데이트되지 않습니다.
이 내에서 onCreate 방법입니다 : 내가 디버깅 할 때, 내가 테 정확한 텍스트로 textviex.settext를 볼 수 있지만이 변경되지
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_incio);
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.HONEYCOMB_MR2) {
ActionBar actionBar = getActionBar();
actionBar.hide();
}
contexto = getApplicationContext();
datos = new ArrayList<Integer>();
recojeDatosDeSesion(savedInstanceState);
adaptador = new AdaptadorImagenes(contexto);
if (getLastNonConfigurationInstance() != null) {
adaptador = (AdaptadorImagenes) getLastNonConfigurationInstance();
}
// Layout
etEmail = (EditText) findViewById(R.id.etEmail);
etPassword = (EditText) findViewById(R.id.etPassword);
tvProgreso = (TextView) findViewById(R.id.tvProgreso);
listaHorizontalImagenes = (Gallery) findViewById(R.id.galeria);
listaHorizontalImagenes.setGravity(Gravity.LEFT);
listaHorizontalImagenes.setAdapter(adaptador);
listaHorizontalImagenes.setSelection(0);
btnDescargar = (Button) findViewById(R.id.btnDescargar);
clickDescargar = new OnClickListener() {
@Override
public void onClick(View v) {
if (!descargaActiva) {
email = etEmail.getText().toString();
password = etPassword.getText().toString();
if (validaDatos(email, password)) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
new DescargaFotos().execute();
descargaActiva = true;
Toast.makeText(contexto, "Comienza la descarga.", Toast.LENGTH_SHORT).show();
tvProgreso.setText("Descargando fotos..");
}
} else {
Toast.makeText(contexto, "Descarga en proceso", Toast.LENGTH_LONG).show();
}
}
};
if (descargaActiva)
btnDescargar.setOnClickListener(null);
else
btnDescargar.setOnClickListener(clickDescargar);
}
및 asyntask
@Override
protected void onProgressUpdate(Integer... progreso) {
// Actualizo el progreso
progresoImagenes = progreso[0];
actualizaTexto(progreso[0]);
adaptador.addItem(progreso[0]);
}
private void actualizaTexto(Integer progreso) {
tvProgreso = (TextView) findViewById(R.id.tvProgreso);
tvProgreso.setText(progreso.toString() + " de " + numeroDeFotos + " fotos.");
}
의 progressUpdate ..
"새"textView를 업데이트 할 수 있습니까? 갤러리가 작동하는 동시에 텍스트 뷰를 업데이트하는 경우 어댑터가있는 갤러리가 있습니까? 방향을 차단할 수 없으며 레이아웃을 변경했기 때문에 활동이 회전 될 때 회전해야합니다. – colymore
신속하고 지저분한 해결책은 매니페스트에서의 활동을 위해'android : configChanges = "orientation | screenSize"'를 추가하는 것입니다. 주제에 대한 자세한 내용을 찾을 수 있습니다 [여기] (http://developer.android.com/guide/topics/resources/runtime-changes.html) –
그래,하지만 할 수 없어 ..;), 감사 – colymore