working on tablet student license icon

parent f2c56467
......@@ -4,6 +4,7 @@ import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Typeface;
import android.provider.ContactsContract;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
......@@ -18,6 +19,10 @@ import com.yottacode.pictogram.tools.PCBcontext;
import java.util.Vector;
import static com.yottacode.pictogram.R.string.fa_certificate;
import static com.yottacode.pictogram.R.string.fa_flask;
import static com.yottacode.pictogram.R.string.fa_exclamation_triangle;
/**
* Creates a View for each student on the list with a photo and his/her name.
* It uses list_single.xml for the layout creation.
......@@ -28,6 +33,7 @@ public class CustomList extends ArrayAdapter<String>{
private final Activity context;
private final String[] name_surname;
private final Vector<Bitmap> images;
private final String[] licenses;
/**
* @param context Context used for rendering the view
......@@ -35,11 +41,12 @@ public class CustomList extends ArrayAdapter<String>{
* @param images List of students' photos
*/
public CustomList(Activity context,
String[] name_surname, Vector<Bitmap> images) {
String[] name_surname, Vector<Bitmap> images, String[] licenses) {
super(context, R.layout.list_single, name_surname);
this.context = context;
this.name_surname = name_surname;
this.images = images;
this.licenses = licenses;
this.color = true;
}
......@@ -53,8 +60,28 @@ public class CustomList extends ArrayAdapter<String>{
public View getView(int position, View view, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View rowView= inflater.inflate(R.layout.list_single, null, true);
// Name
TextView txtTitle = (TextView) rowView.findViewById(R.id.loginStudentName);
// License
TextView licenseView = (TextView) rowView.findViewById(R.id.loginStudentLicense);
switch (licenses[position]) {
case "pro":
licenseView.setText(fa_certificate);
break;
case "b":
licenseView.setText(fa_flask);
break;
default:
licenseView.setText(fa_exclamation_triangle);
}
Typeface font = Typeface.createFromAsset( getContext().getAssets(), "fonts/fontawesome-webfont.ttf" );
licenseView.setTypeface(font);
// Image
ImageView imageView = (ImageView) rowView.findViewById(R.id.loginStudentPhoto);
txtTitle.setText(name_surname[position]);
......
......@@ -36,15 +36,27 @@
android:layout_gravity="center" />
</FrameLayout>
<TextView
android:id="@+id/loginStudentName"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_below="@+id/loginStudentPhoto"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/loginStudentLicense"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="1dp" />
<TextView
android:id="@+id/loginStudentName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/loginStudentPhoto"
android:layout_centerHorizontal="false"
android:layout_gravity="center"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</LinearLayout>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment