Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!