Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
7859 views
1
package com.artifex.mupdfdemo;
2
3
import android.view.LayoutInflater;
4
import android.view.View;
5
import android.view.ViewGroup;
6
import android.widget.BaseAdapter;
7
import android.widget.TextView;
8
9
public class OutlineAdapter extends BaseAdapter {
10
private final OutlineItem mItems[];
11
private final LayoutInflater mInflater;
12
public OutlineAdapter(LayoutInflater inflater, OutlineItem items[]) {
13
mInflater = inflater;
14
mItems = items;
15
}
16
17
public int getCount() {
18
return mItems.length;
19
}
20
21
public Object getItem(int arg0) {
22
return null;
23
}
24
25
public long getItemId(int arg0) {
26
return 0;
27
}
28
29
public View getView(int position, View convertView, ViewGroup parent) {
30
View v;
31
if (convertView == null) {
32
v = mInflater.inflate(R.layout.outline_entry, null);
33
} else {
34
v = convertView;
35
}
36
int level = mItems[position].level;
37
if (level > 8) level = 8;
38
String space = "";
39
for (int i=0; i<level;i++)
40
space += " ";
41
((TextView)v.findViewById(R.id.title)).setText(space+mItems[position].title);
42
((TextView)v.findViewById(R.id.page)).setText(String.valueOf(mItems[position].page+1));
43
return v;
44
}
45
46
}
47
48