How to show selected View in an Activity first

I have a activity in Android TextView followed ListView again TextView. The content of first TextView fills the whole screen and in order to see the ListView and second TextView the user has to scrolldown. Now I wish to show the second TextView when activity start instead of first TextView.

Instead I want TextView2 to be visible when activity starts.

EDITED

Sample code as per advice of @Urban

public class FocusTestActivity extends Activity {
private static final String TAG = "FocusTestActivity";
ScrollView scroll;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    TextView text1 = (TextView) findViewById(R.id.text1);
    TextView text2 = (TextView) findViewById(R.id.text2);
    TextView text3 = (TextView) findViewById(R.id.text3);
    String hello = "We provide services to K-12 education sector."
            + "Our services include Feasibility report, Marketing, Curriculum design"
            + "Teachers planning, Design and Technology, Parents expectation"
            + "management, Transport planning, Day-to-day operations and Statutory"
            + "compliances. Please find a brief introduction attached with mail. Also visit"
            + "www.wissenways.com We can help you with overall process of setting-up school. We have"
            + "experience include establishing International, pre-school and CBSE"
            + "schools from scratch. Please feel free to contact if you need some help in your school venture."
            + "Best of Luck!<br/><br/>";

    text1.setText(Html.fromHtml(hello));
    text2.setText(Html.fromHtml(hello));
    text3.setText(Html.fromHtml(hello));
    ScrollView scroll = (ScrollView) findViewById(R.id.scrollcontainer);
}

public void onStart() {
    super.onStart();
    Log.d(TAG,"Inside onStart");
    scroll.post(new Runnable() {

        @Override
        public void run() {
            scroll.fullScroll(ScrollView.FOCUS_DOWN);
        }
    });
}

}

XML Code

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@+id/scrollcontainer"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent">
   <LinearLayout android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
    android:id="@+id/text1"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    android:textSize="17sp"/>
<TextView  
    android:id="@+id/text2"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    android:textSize="17sp"/>
<TextView  
    android:id="@+id/text3"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    android:textSize="17sp"/>
</LinearLayout>
</ScrollView>

LOGCAT output:

Answers


getScrollView().post(new Runnable() {

    @Override
    public void run() {
        getScrollView().fullScroll(ScrollView.FOCUS_DOWN);
    }
});

Using this code in the onCreate should start the scrollview (in which your list and two text views are) at the bottom position. I dont know why you would want to do that, and im guessing there could be a better way to do what you want rather than forcing the scroll position to the bottom, but anyways... This is the question from where the above code is taken from, you couldve searched for it.

Hope this helped.


Need Your Help

SendKeys strange behaviour on Windows XP in C#

c# windows-xp sendkeys

I am using SendKeys in one of my program (C#) which copies selected text when a user presses F8 on keyboard.

Html.Raw doesn't close empty elements

html asp.net-mvc-4 xhtml

Using ASP.Net MVC 4 I have the following in a view:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.