得到父类的私有属性

android.widget.ArrayAdapter类mObjects为私有属性:private List<T> mObjects;若要获取这个属性:可以在子类中定义一个属性,把这个属性赋值给mObjects

代码如下:
getObjects()就会获取父类的私有属性
 1 import android.content.Context;
 2 import android.view.View;
 3 import android.view.ViewGroup;
 4 import android.widget.ArrayAdapter;
 5 import android.widget.ImageView;
 6 import android.widget.LinearLayout;
 7 import android.widget.TextView;
 8 
 9 import com.ozner.WaterPurifier.WaterPurifierManager;
10 import com.ozner.cup.CupManager;
11 import com.ozner.tap.TapManager;
12 
13 import net.ozner.oznerproject.Command.DeviceData;
14 import net.ozner.oznerproject.R;
15 
16 import java.util.ArrayList;
17 import java.util.List;
18 
19 /**
20  * Created by admin on 2015/11/26.
21  */
22 public class SlideAdapter extends ArrayAdapter<DeviceData> {
23 
24     static SlideAdapter instance;
25     private List<DeviceData> slideBeans;
26     public List<View> myViewGroup = new ArrayList<View>();
27     public View lastview;
28     public final String[] constate = new String[]{"未连接", "正在连接", "已连接"};
29 
30     public SlideAdapter(Context context, List<DeviceData> deviceDatas) {
31         super(context, R.layout.list_item_handle_left, R.id.title_text, deviceDatas);
32         this.slideBeans = deviceDatas;
33         instance = this;
34     }
35 
36     public static SlideAdapter instance() {
37         return instance;
38     }
39 
40     /**
41      * 拖动之后的列表
42      *
43      * @return
44      */
45     public List<DeviceData> getSortList() {
46         ArrayList<DeviceData> list = new ArrayList<DeviceData>();
47         int n = getCount();
48         for (int i = 0; i < n; i++) {
49             list.add(getItem(i));
50         }
51         return list;
52     }
53 
54     /**
55      * 拖动之后的列表
56      *
57      * @return
58      */
59     public List<DeviceData> getObjects() {
60         return slideBeans;
61     }
62 
63 //......
64 
65 }

 

 

posted on 2016-01-21 17:34  皮皮鲁西西  阅读(908)  评论(0编辑  收藏  举报

导航