Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

115
Vistas
Android TextView with limited amount of items and special functionality

I want to have a multiline text view and adding text to it,

After adding five lines to the TextView I want to start to add to the beginning of the text view.

For example: (numbers as text), 1,2,3,4,5 -> 6,2,3,4,5 -> 6,7,3,4,5 and so on.

I thought about using StringBuilder but I don't see an efficient way to implement this.

The delimiter of each row is "\n\n" maybe it will help to solve the problem.

Or maybe should I just do 5 textView's and have some switch case between them?

Button xml:

<TextView
    android:id="@+id/searchesInputTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scrollHorizontally="false"
    android:width="300dp"
    android:height="200dp"
    android:background="@drawable/border_style"
    android:maxLines="5"
    android:layout_marginTop="24dp"
    />

in MainActivity.java:

public class MainActivity extends AppCompatActivity {
    private TextView searchesTextView;
    private ImageButton refreshCurrentLocationButton;
    private String myText = "";

 refreshCurrentLocationButton = (ImageButton) findViewById(R.id.currentLocationRefreshImageButton);
searchesTextView = (TextView) findViewById(R.id.searchesInputTextView);



refreshCurrentLocationButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
// Actual code
myText += location.ToString() + "\n\n";
searchesTextView.setText(myText);

  });
}
over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda