0
I am new to programming for Android and would like to troubleshoot this error:
package br.pedromazer.cantoliturgico;
import br.pedromazer.cantoliturgico.R.string;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.ListView;
public class Lista extends Activity {
@Override
protected void onCreate(Bundle b) {
// TODO Auto-generated method stub
super.onCreate(b);
setContentView(R.layout.lista);
btnVoltar = (ImageButton) this.findViewById(R.id.btnVoltar);
btnVoltar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Ao invés de trabalhar aqui, criar um evento cf. acima do ImageButton
//Aqui chama o método com um evento
btnVoltar_onClick(v);
}
});
lstAlunos = (ListView) this.findViewById(R.id.lstAlunos);
ArrayAdapter<string> array = new
ArrayAdapter<string> (this, android.R.layout.simple_list_item_single_choice), alunos;
lstAlunos.setAdapter(array);
lstAlunos.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
lstView_onClick(v);
}
});
}
public void btnVoltar_onClick(View v) {
this.finish();
}
public void lstView_onClick(View v) {
Intent i = new Intent(this, Lista.class);
this.startActivity(i);
}
String[] alunos = ***new String[]***("Aluno A", "Aluno B", "Aluno C");
ImageButton btnVoltar;
ListView lstAlunos;
}
Are you sure this is how to instance a Java array (
***new String[]***("Aluno A", "Aluno B", "Aluno C");
)? Shouldn’t benew String[] {"Aluno A", "Aluno B", "Aluno C"};
. Another error is that you are usingstring
as the type ofAdapter
, should beString
.– Wakim