Changed ListView to GridView for admin welcome page

This commit is contained in:
Mary Tran 2018-10-22 23:09:55 -04:00
parent 5ebf406850
commit 27bc56bc7f
2 changed files with 11 additions and 18 deletions

View file

@ -2,7 +2,9 @@ package com.uottawa.olympus.olympusservices;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
@ -18,22 +20,18 @@ public class AdminWelcome extends AppCompatActivity {
DBHelper dbHelper = new DBHelper(this); DBHelper dbHelper = new DBHelper(this);
List<String[]> users = dbHelper.getAllUsers(); List<String[]> users = dbHelper.getAllUsers();
String[] usernames = new String[users.size()+1]; String[] usernames = new String[(users.size()+1)*2];
String[] usertypes = new String[users.size()+1];
usernames[0] = "Username"; usernames[0] = "Username";
usertypes[0] = "User Type"; usernames[1] = "User Type";
Iterator iter = users.iterator(); Iterator iter = users.iterator();
for (int i=0; i<users.size();i++){ for (int i=0; i<users.size();i++){
String[] current = (String[])iter.next(); String[] current = (String[])iter.next();
usernames[i+1] = current[0]; usernames[(i+1)*2] = current[0];
usertypes[i+1] = current[3]; usernames[(i+1)*2+1] = current[3];
} }
ArrayAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, usernames); ArrayAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, usernames);
ListView listView = (ListView) findViewById(R.id.Users); GridView gridView = (GridView) findViewById(R.id.Users);
listView.setAdapter(adapter); gridView.setAdapter(adapter);
ArrayAdapter adapter2 = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, usertypes);
ListView listView2 = (ListView) findViewById(R.id.Types);
listView2.setAdapter(adapter2);
} }
} }

View file

@ -30,20 +30,15 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal"> android:orientation="horizontal">
<ListView <GridView
android:id="@+id/Users" android:id="@+id/Users"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="match_parent" android:layout_height="match_parent"
android:numColumns="2"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="15sp" /> android:textSize="15sp" />
<ListView
android:id="@+id/Types"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="match_parent"
android:textColor="@android:color/white"
android:textSize="15sp" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>