2

I am working on an application that functions like a text messaging app. I am working on the layout of the app now. In the XML file I have an edit text on the top of the screen and one on the bottom of the screen. I want to dynamically create a scrollview that would be between the 2 edit texts. The scroll view would enable to scroll through multiple messages of the app. When I try to create the scrollview and textview dynamically it replaces the edittexts and they disappear.

So my question is how would I go about preventing the edittexts from disappearing and adding a scrollview in between the 2 edit texts ?

My code is like this:

   ScrollView sv = new ScrollView(this);
   LinearLayout ll = new LinearLayout(this);
   ll.setOrientation(LinearLayout.VERTICAL);
   sv.addview(ll);

    TextView tv = new TextView(this);
    tv.setText("Dynamic layouts ftw!");
    ll.addView(tv);
    this.setContentView(sv);
1
  • what happen when u are running this code? Commented Jun 4, 2012 at 15:31

1 Answer 1

3

What you are asking to do is build a ListView. ListView'ss have every function you require and more. Further, with the adapters, they are pretty quick. Here is a decent turorial on using ListViews.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.