I have a simple Activity that displays an EditText and a ListView. The ListView will be populated once a JSON is fetched from a URL, this can sometimes take a while (3-5 seconds).
I want to instantaneously display the EditText (a search field), and then add the ListView once the JSON has been fetched and processed.
My main.xml:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<EditText
android:id="@+id/search"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:padding="10dp"
android:includeFontPadding="true"
android:backgroundTint="@android:color/darker_gray"
android:textSize="15sp"
android:drawableRight="@drawable/search_icon"/>
</LinearLayout>
I create the ListView programatically and add it as such:
View rootView = findViewById(android.R.id.content);
addContentView(suggestions,rootView.getLayoutParams());
This makes the ListView start at the same position as EditText and I can't seem to get it to start directly below it. Any suggestions?
I have read about ViewStubs, ProgressBars (having a spinner while the JSON is getting fetched) and Fragments etc. I'm relatively new to Android but been working with Java for some time and find the whole handling of Views complex so any suggestions on material there is helpful.
Thanks in advance.