Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

114
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda