When I open my activity the first time, all settexts are null, the second time it works normally, what's wrong?
Settext activity ..
autor = (TextView) findViewById(R.id.tv1);
editora = (TextView) findViewById(R.id.tv2);
isbntv = (TextView) findViewById(R.id.tv3);
paginas = (TextView) findViewById(R.id.tv4);
edicao = (TextView) findViewById(R.id.tv5);
ano = (TextView) findViewById(R.id.tv6);
idioma = (TextView) findViewById(R.id.tv7);
infliv = (TextView) findViewById(R.id.tv9);
imageView = (ImageView) findViewById(R.id.imageView2);
buy = (Button) findViewById(R.id.buttonbuy);
id = (TextView) findViewById(R.id.id_user);
valor = (TextView) findViewById(R.id.preço1);
Intent intent = getIntent();
mIsbn = intent.getStringExtra("mIsbn");
mDesc = intent.getStringExtra("mDesc");
mAut = intent.getStringExtra("mAut");
mVl_anun = intent.getStringExtra("mVl_anun");
mAno = intent.getStringExtra("mAno");
mImg = intent.getStringExtra("mImg");
mEdic = intent.getStringExtra("mEdic");
mIdi = intent.getStringExtra("mIdi");
mPag = intent.getStringExtra("mPag");
medicao = intent.getStringExtra("mEd");
autor.setText(mAut);
editora.setText(mEdic);
isbntv.setText(mIsbn);
paginas.setText(mPag);
edicao.setText(medicao);
ano.setText(mAno);
idioma.setText(mIdi);
infliv.setText(mDesc);
valor.setText(mVl_anun);
Activity that passes the text object ..
final ListView listViewLivros = (ListView) findViewById(R.id.lista_livros);
ListaLivroAdapter adapter = new ListaLivroAdapter(listaLivros, this);
listViewLivros.setAdapter(adapter);
listViewLivros.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
c = (TextView) view.findViewById(R.id.lista_livro_descricao);
idliv_select = c.getText().toString();
postId("http://xxxxxxxxxx/api/v2/bookdemo/_table/cad_livro?fields=qt_pag%2Cisbn%2Cano%2Cid_ed%2Cdexxxxxxxxxx_ed%2Cid_aut%2Cid_idi&filter=id_liv%20%3D%20"+idliv_select, 2);
Intent myIntent = new Intent(view.getContext(), ActivityCompra.class);
myIntent.putExtra("mIsbn",ISBN);
myIntent.putExtra("mDesc",desc);
myIntent.putExtra("mAut",autor);
myIntent.putExtra("mVl_anun",vl_anuncio);
myIntent.putExtra("mAno",ano);
myIntent.putExtra("mImg",img);
myIntent.putExtra("mEdic",edicao);
myIntent.putExtra("mIdi",idioma);
myIntent.putExtra("mPag",paglivro);
myIntent.putExtra("mEd",medicao);
startActivityForResult(myIntent, 2);
}
});
}
Post id:
private void postId(String url, int seq) {
HttpConnectionListBooks postId = new HttpConnectionListBooks(ListViewLivrosActivity.this, desc, url, seq);
postId.execute();
}