0

I display a ListView that should contain a TextView followed by a ProgressBar (underneath it).

So far I only display a TextViews like such:

In my Activity.xml:

<fragment
      android:id="@+id/routineFragment"
      android:name="kade_c.trakr.fragments.RoutineListFragment"
      android:layout_width="match_parent"
      android:layout_height="match_parent" />

In my RoutineListFragment.java that extends ListFragment:

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    ArrayAdapter adapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.routine, android.R.layout.simple_list_item_1);
    setListAdapter(adapter);

    getListView().setOnItemClickListener(this);
}

And finally my fragment_routine_list.xml that contains my ListView:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:id="@+id/RoutineLayout">

    <ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </ListView>    

</LinearLayout>

How may I add a ProgressBar under each TextView contained in my ListView?

Forgive me if this question is too broad, but I can't seem to find an answer anywhere.

  • Instead of using `android.R.layout.simple_list_item_1` layout use custom layout with ProgressBar – ρяσѕρєя K Jan 06 '17 at 08:17
  • You'll need to create a custom adapter, so you can set the value for the text view and the progress bar. See duplicate for details on that, or google "Custom listview adapter" – Gabe Sechan Jan 06 '17 at 08:18

0 Answers0