1
I’m trying to concatenate a text into CharSequence
with int
, but java warns that it is not possible to do this conversion by saying:
The Operator + is Undefined for the argument type(s) Charsequence, int
I already tried to remove the casting of CharSequence
, in addition to "give" a .toString()
in everything, but the app doesn’t start when I do it.
package br.edu.ifgoiano.cadastrodeprodutos;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
public class Cadastrar extends Activity {
Principal principal = new Principal();
/* private int cont = 0;
private int varAux;*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cadastrar);
}
public void tirarFoto(View view) {
Intent tiraFoto = new Intent("android.media.action.IMAGE_CAPTURE");
startActivityForResult(tiraFoto, 0);
}
**public void qntProd() {
int cont = 0;
if (cont == 0) {
principal.quanti.setText((CharSequence) "Você não possui produtos cadastrados.");
} else {
principal.quanti.setText("Você possui " + cont +" produtos cadastrados.");
}**
}
/*public int qntProdCadastrados() {
if(cont == 0) {
varAux = cont;
}else if(cont > 0){
varAux = cont;
}
cont++;
return varAux;
}*/
public void enviar(View view) {
Toast.makeText(this, "O cadastro foi realizado com sucesso", Toast.LENGTH_LONG).show();
Intent telaInicial = new Intent(this, Principal.class);
startActivity(telaInicial);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
if(data != null) {
Bundle bundle = data.getExtras();
if(bundle != null) {
Bitmap img = (Bitmap) bundle.get("data");
ImageView imagem = (ImageView) findViewById(R.id.imagem);
imagem.setImageBitmap(img);
}
}
}
}
What is
quanti
? Why are you wearing(CharSequence)
?– Maniero
Pardoning...
quanti
is the Textview that will write on the screen. I am using Charsequence because theTextView
uses a string of characters.– Marcos Paulo S. Rezende