-
Notifications
You must be signed in to change notification settings - Fork 0
/
DrawerAdapter.java
76 lines (60 loc) · 1.97 KB
/
DrawerAdapter.java
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
72
73
74
75
76
package com.d_andaman;
import android.content.Context;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
public class DrawerAdapter extends ArrayAdapter<String>{
public static int[] type={1,2,2,2,3,3};
public Typeface typeface;
public DrawerAdapter(Context context,String[] item,Typeface typeface) {
super(context,-1,item);
this.typeface=typeface;
}
@Override
public int getViewTypeCount() {
// TODO Auto-generated method stub
return 5;
}
@Override
public int getItemViewType(int position) {
// TODO Auto-generated method stub
return type[position];
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
Drawer_data_holder holder;
int laytype=getItemViewType(position);
if(row == null) {
if(laytype==1){
row = LayoutInflater.from(getContext()).inflate(R.layout.list_view, parent, false);
TextView text = (TextView)row.findViewById(R.id.list_text);
String item = (String) getItem(position);
text.setText(item);
ImageView left =(ImageView)row.findViewById(R.id.list_img);
left.setImageResource(R.drawable.emblom);
}
if(laytype==2){
row = LayoutInflater.from(getContext()).inflate(R.layout.data_list, parent, false);
String item = (String) getItem(position);
TextView text = (TextView)row.findViewById(R.id.textdata);
text.setTypeface(typeface);
text.setText(item);
}
if(laytype==3){
row = LayoutInflater.from(getContext()).inflate(R.layout.small_data, parent, false);
TextView text = (TextView)row.findViewById(R.id.notitext);
String item = (String) getItem(position);
text.setText(item);
ImageView left =(ImageView)row.findViewById(R.id.notiimage);
left.setImageResource(R.drawable.main);
}
}
return row;
}
}