-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGridViewAdapter.java
More file actions
executable file
·71 lines (55 loc) · 1.8 KB
/
GridViewAdapter.java
File metadata and controls
executable file
·71 lines (55 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.tobedecided.dynamicdialer;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
public class GridViewAdapter extends BaseAdapter {
private final Context mContext;
private final int[] digits;
private final String[] alphanum;
// 1
public GridViewAdapter(Context context, int[] digits, String[] alphanum) {
this.mContext = context;
this.digits = digits;
this.alphanum = alphanum;
}
// 2
@Override
public int getCount() {
return digits.length;
}
// 3
@Override
public long getItemId(int position) {
return 0;
}
// 4
@Override
public Object getItem(int position) {
return null;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final String alphanumf = alphanum[(position + 1) % 12];
if (convertView == null) {
final LayoutInflater layoutInflater = LayoutInflater.from(mContext);
convertView = layoutInflater.inflate(R.layout.digit_layout, null);
}
final TextView nameTextView = (TextView) convertView.findViewById(R.id.number);
final TextView alphanumText = (TextView) convertView.findViewById(R.id.alpha_num);
if (position < 9) {
nameTextView.setText("" + (position + 1));
alphanumText.setText(alphanumf);
} else if (position == 9) {
nameTextView.setText("*");
} else if (position == 10) {
nameTextView.setText("0");
alphanumText.setText(" +");
} else if (position == 11) {
nameTextView.setText("#");
}
return convertView;
}
}