David_Garcia
David_Garcia

Reputation: 654

TextView weird behavior

I got a weird behavior in my textview. When i load a large text, and you need to scroll dawn if i refresh whit new text the same textview the "focus of the scroll" still be down and I dont know how to fix it...

So my textView is like this:

<TextView
        android:id="@+id/txtTexto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="26dp"
        android:text="Medium Text"
        android:maxLines= "5000"
        android:scrollbars="vertical"            
        android:textAppearance="?android:attr/textAppearanceMedium" />

And the definition in the Activity is this:

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_text);

        texto = this.getIntent().getStringExtra("memorization");
        this.inicializar(texto); 
             .........`

private void inicializar(String texto){
    txtv = (TextView) this.findViewById(R.id.txtTexto);
    txtv.setMovementMethod(new ScrollingMovementMethod());      
    txtv.setText(texto);
}

I Change the "texto" and I call the textview like this

        boton.setText(R.string.animar);
        this.inicializar(texto_memorizado);

Someone can help me please? Thanks a lot!!!

Upvotes: 1

Views: 105

Answers (1)

Triode
Triode

Reputation: 11359

android:id="@+id/textView1" 

Since your text id is this try this,

private void inicializar(String texto){
    txtv = (TextView) this.findViewById(R.id.textView1);
    txtv.setMovementMethod(new ScrollingMovementMethod());      
    txtv.setText(texto);
}

Upvotes: 1

Related Questions