add indicator message for no bikes
This commit is contained in:
parent
6d313522d4
commit
d36acfa86e
2 changed files with 13 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ import android.view.MenuItem;
|
|||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
|
@ -136,6 +137,11 @@ public class MainActivity extends AppCompatActivity implements AsyncTaskCallback
|
|||
android.R.layout.simple_list_item_1, list);
|
||||
listview.setAdapter(adapter);
|
||||
|
||||
//Print indicator if empty
|
||||
TextView tv = findViewById(R.id.noBikes);
|
||||
if(list.isEmpty()) tv.setVisibility(View.VISIBLE);
|
||||
else tv.setVisibility(View.INVISIBLE);
|
||||
|
||||
try {
|
||||
final JSONObject jObject = new JSONObject(response);
|
||||
final JSONArray bikesArray = jObject.getJSONArray("rentalCollection");
|
||||
|
|
|
|||
|
|
@ -7,6 +7,13 @@
|
|||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:context=".MainActivity"
|
||||
tools:showIn="@layout/activity_main">
|
||||
<TextView
|
||||
android:id="@+id/noBikes"
|
||||
android:gravity="center"
|
||||
android:textSize="20sp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/indicator_no_bikes" />
|
||||
|
||||
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/listview"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue