Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add file items

  • Loading branch information...
commit cd26da5fb2337693a3a4ec6e300fa06aaf0cc664 1 parent f1d6123
@exallium authored
View
18 res/layout/fileitem.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="48dip"
+ android:orientation="horizontal" >
+
+ <TextView
+ android:id="@+id/listitem_title"
+ android:padding="8dip"
+ android:drawableLeft="@drawable/ic_launcher"
+ android:drawablePadding="8dip"
+ android:textAppearance="@android:style/TextAppearance.Medium"
+ android:gravity="center_vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ />
+
+</LinearLayout>
View
54 src/com/exallium/expressfiles/adapters/FileAdapter.java
@@ -0,0 +1,54 @@
+package com.exallium.expressfiles.adapters;
+
+import java.io.File;
+import java.util.List;
+
+import com.exallium.expressfiles.R;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.TextView;
+
+public class FileAdapter extends ArrayAdapter<File> {
+
+ private List<File> objects;
+ private Context context;
+
+ public FileAdapter(Context context, int textViewResourceId,
+ List<File> objects) {
+ super(context, textViewResourceId, objects);
+
+ this.context = context;
+ this.objects = objects;
+
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+
+ View v = convertView;
+
+ if (v == null) {
+ LayoutInflater inflater = (LayoutInflater) this.context
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ v = inflater.inflate(R.layout.fileitem, null);
+ }
+
+ File file = objects.get(position);
+
+ TextView title = (TextView) v.findViewById(R.id.listitem_title);
+
+ try {
+ title.setText(file.getName());
+ } catch (Exception e) {
+ e.printStackTrace();
+ title.setText("<ERROR, PLEASE REFER TO LOGCAT>");
+ }
+
+ return v;
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.