Galera is as follows. I would like to know how to add a paragraph or a single word to a textview that already contains content without necessarily copying what already has in it. I would like you to show me something that would suit any text.
An example of what I want exactly:
Ifthecheckboxischeckedthetextdisplayedis"Neo is". Otherwise "Neo is not".
AsIclickthe"+1" button I want it to be added after the content already exists in the textview (Neo is / Neo is not) the status corresponding to the value of the cont variable.
If it contains == 1 = > existing text + single. If it contains == 2 = > existing text + dating. If it contains == 3 = > existing text + married.
package genesysgeneration.wwww;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
private TextView tv01;
private Button btnMais1;
private int cont=0;
private CheckBox cbNeo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv01=(TextView)findViewById(R.id.tv01);
addCheckBoxCondiction();
addComplementText();
btnMais1=(Button)findViewById(R.id.btnMais1);
btnMais1.setOnClickListener(this);
}
public void addCheckBoxCondiction(){
cbNeo=(CheckBox)findViewById(R.id.cbNeo);
cbNeo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(((CheckBox)v).isChecked()){
tv01.setText(String.valueOf("Neo está"));
}else{
tv01.setText(String.valueOf("Neo não está"));
}
}
});
}
public void addComplementText(){
if(cont==1){
//tv01 => texto já existente + solteiro
}
if(cont==2){
//tv01 => texto já existente + namorando
}
if(cont==3){
//tv01 => texto já existente + casado
}
}
public void onClick(View v){
cont+=1;
}
}