I created a custom layout for my AlertDialog with a TextView in it, and an image, but I can not put values in it. Does anyone know how to solve it?
Follow the code:
private void carregaAlert(){
View v = getLayoutInflater().inflate(R.layout.alerta, null);
AlertDialog.Builder dialog = new AlertDialog.Builder(ClassificacaoActivity.this);
dialog.setView(v).setPositiveButton("SIM", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
Intent vai = new Intent(ClassificacaoActivity.this, InteraActivity.class);
startActivity(vai);
}
}).setNegativeButton("NÃO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
// Continua na tela
}
});
ImageView img = (ImageView) findViewById(R.id.ima);
img.setImageResource(R.drawable.trofeu);
dialog.show();
}
10-13 21:50:52.280 844-844/? I/art: Not late-enabling -Xcheck:jni (already on) 10-13 21:50:52.280 844-844/? W/art: Unexpected CPU variant for X86 using defaults: x86 10-13 21:50:52.482 844-844/br.com.franciscocartaxo.aps2 W/System: ClassLoader referenced unknown path: /data/app/br.com.franciscocartaxo.aps2-1/lib/x86 10-13 21:50:52.502 844-844/br.com.franciscocartaxo.aps2 I/InstantRun: starting instant run server: is main process 10-13 21:50:52.644 844-844/br.com.franciscocartaxo.aps2 W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 10-13 21:50:52.884 844-874/br.com.franciscocartaxo.aps2 I/OpenGLRenderer: Initialized EGL, version 1.4 10-13 21:50:52.885 844-874/br.com.franciscocartaxo.aps2 D/OpenGLRenderer: Swap behavior 1 10-13 21:50:52.893 844-874/br.com.franciscocartaxo.aps2 D/EGL_emulation: eglCreateContext: 0xa2817a60: maj 2 min 0 rcv 2 10-13 21:50:52.912 844-874/br.com.franciscocartaxo.aps2 D/EGL_emulation: eglMakeCurrent: 0xa2817a60: ver 2 0 (tinfo 0xa2854330) 10-13 21:50:52.938 844-874/br.com.franciscocartaxo.aps2 D/EGL_emulation: eglMakeCurrent: 0xa2817a60: ver 2 0 (tinfo 0xa2854330) 10-13 21:50:56.047 844-844/br.com.franciscocartaxo.aps2 W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView 10-13 21:50:56.056 844-874/br.com.franciscocartaxo.aps2 D/EGL_emulation: eglMakeCurrent: 0xa2817a60: ver 2 0 (tinfo 0xa2854330)