android 实现调查问卷-单选-多选

转载请加地址:http://blog.****.net/jing110fei/article/details/46618229

先上效果图

android 实现调查问卷-单选-多选

android 实现调查问卷-单选-多选

个人分析,最好是用动态布局加载来实现,好了,说思路,将这整体分为3块

android 实现调查问卷-单选-多选

最外面这个布局里面,根据第二层问题的数量来动态生成布局,加入在第一层布局里面,

然后再根据问题下答案的数量来动态生成布局,加入第二层布局里面,思路这么透彻,想想还有些小激动呢。

先建造三个实体类

[java] view plain copy
  1. public class Page {  
  2.     //问卷id  
  3.     private String pageId;  
  4.     //问卷状态  
  5.     private String status;  
  6.     //问卷主题  
  7.     private String title;  
  8.     //题目  
  9.     private ArrayList<Quesition> quesitions;  
  10.       
  11.       
  12.     public ArrayList<Quesition> getQuesitions() {  
  13.         return quesitions;  
  14.     }  
  15.     public void setQuesitions(ArrayList<Quesition> quesitions) {  
  16.         this.quesitions = quesitions;  
  17.     }  
  18.       
  19.     public String getPageId() {  
  20.         return pageId;  
  21.     }  
  22.     public void setPageId(String pageId) {  
  23.         this.pageId = pageId;  
  24.     }  
  25.     public String getStatus() {  
  26.         return status;  
  27.     }  
  28.     public void setStatus(String status) {  
  29.         this.status = status;  
  30.     }  
  31.     public String getTitle() {  
  32.         return title;  
  33.     }  
  34.     public void setTitle(String title) {  
  35.         this.title = title;  
  36.     }  
  37.       
  38. }  
[java] view plain copy
  1. public class Quesition {  
  2.     //题目id  
  3.     private String quesitionId;  
  4.     //单选多选标识  
  5.     private String type;  
  6.     //题目  
  7.     private String content;  
  8.     //选项  
  9.     private ArrayList<Answer> answers;  
  10.     //是否解答  
  11.     private int que_state;  
  12.       
  13.       
  14.     public int getQue_state() {  
  15.         return que_state;  
  16.     }  
  17.     public void setQue_state(int que_state) {  
  18.         this.que_state = que_state;  
  19.     }  
  20.       
  21.     public String getQuesitionId() {  
  22.         return quesitionId;  
  23.     }  
  24.     public void setQuesitionId(String quesitionId) {  
  25.         this.quesitionId = quesitionId;  
  26.     }  
  27.     public String getType() {  
  28.         return type;  
  29.     }  
  30.     public void setType(String type) {  
  31.         this.type = type;  
  32.     }  
  33.     public String getContent() {  
  34.         return content;  
  35.     }  
  36.     public void setContent(String content) {  
  37.         this.content = content;  
  38.     }  
  39.     public ArrayList<Answer> getAnswers() {  
  40.         return answers;  
  41.     }  
  42.     public void setAnswers(ArrayList<Answer> answers) {  
  43.         this.answers = answers;  
  44.     }  
  45.       
  46. }  
[java] view plain copy
  1. public class Answer {  
  2.     //答案id  
  3.     private String answerId;  
  4.     //答案主体  
  5.     private String answer_content;  
  6.     //答案是否被解答  
  7.     private int ans_state;  
  8.       
  9.     public int getAns_state() {  
  10.         return ans_state;  
  11.     }  
  12.     public void setAns_state(int ans_state) {  
  13.         this.ans_state = ans_state;  
  14.     }  
  15.     public String getAnswerId() {  
  16.         return answerId;  
  17.     }  
  18.     public void setAnswerId(String answerId) {  
  19.         this.answerId = answerId;  
  20.     }  
  21.     public String getAnswer_content() {  
  22.         return answer_content;  
  23.     }  
  24.     public void setAnswer_content(String answer_content) {  
  25.         this.answer_content = answer_content;  
  26.     }  
  27.       
  28. }  
建造这三个实体类的目的是为了在做demo的时候直接通过假数据来尽可能的贴近项目,使demo完成后能尽快的移植进项目。

下面来看看布局,总工用到了3个布局。

首先是activity_main.xml

[java] view plain copy
  1. <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     xmlns:tools="http://schemas.android.com/tools"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.     android:background="#e6e4e3" >  
  6.   
  7.     <LinearLayout  
  8.         android:layout_width="match_parent"  
  9.         android:layout_height="match_parent"  
  10.         android:orientation="vertical"   
  11.           
  12.         >  
  13.   
  14.         <LinearLayout  
  15.             android:layout_width="match_parent"  
  16.             android:layout_height="wrap_content"  
  17.             android:background="#EA5514"  
  18.             android:orientation="horizontal" >  
  19.             <ImageView   
  20.                 android:id="@+id/test_back"  
  21.                 android:layout_width="wrap_content"  
  22.                 android:layout_height="wrap_content"  
  23.                 android:layout_gravity="left|center_vertical"  
  24.                 android:layout_marginLeft="5dp"  
  25.                 android:padding="5dp"  
  26.                 android:background="@drawable/ic_back_white"  
  27.                   
  28.                 />  
  29.             <TextView   
  30.                 android:layout_width="0dp"  
  31.                 android:layout_height="wrap_content"  
  32.                 android:layout_weight="1"  
  33.                 android:text="调查问卷"  
  34.                 android:textSize="18sp"  
  35.                 android:textColor="@android:color/white"  
  36.                 android:layout_gravity="center"  
  37.                 android:gravity="center"/>  
  38.         </LinearLayout>  
  39.         <TextView  
  40.             android:id="@+id/txt_title"   
  41.             android:layout_width="match_parent"  
  42.             android:layout_height="wrap_content"  
  43.             android:textSize="10sp"  
  44.             android:layout_marginTop="40dp"  
  45.             android:layout_marginLeft="30dp"  
  46.             android:textColor="#898989"  
  47.             />  
  48.         <LinearLayout   
  49.             android:id="@+id/lly_test"  
  50.             android:layout_width="match_parent"  
  51.             android:layout_height="wrap_content"  
  52.             android:orientation="vertical">  
  53.               
  54.         </LinearLayout>  
  55.         <LinearLayout  
  56.             android:layout_width="match_parent"  
  57.             android:layout_height="wrap_content"  
  58.             android:orientation="vertical"  
  59.             >  
  60.             <Button  
  61.                 android:id="@+id/submit"  
  62.                 android:layout_width="wrap_content"  
  63.                 android:layout_height="wrap_content"  
  64.                 android:layout_marginTop="50dp"  
  65.                 android:layout_marginBottom="30dp"  
  66.                 android:text="提交"  
  67.                 android:textSize="20sp"  
  68.                 android:textColor="@android:color/white"  
  69.                 android:layout_gravity="center"  
  70.                 android:gravity="center"  
  71.                 android:background="@drawable/button_submit"/>  
  72.         </LinearLayout>  
  73.     </LinearLayout>  
  74.   
  75. </ScrollView>  
id为lly_test的布局就是最终要加入的目的布局

然后是quesition_layout.xml

[java] view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="wrap_content"  
  5.     android:orientation="vertical"  
  6.     android:paddingTop="35dp"  
  7.       
  8.      >  
  9.     <TextView   
  10.         android:id="@+id/txt_question_item"  
  11.         android:layout_width="match_parent"  
  12.         android:layout_height="wrap_content"  
  13.         android:textSize="14sp"  
  14.         android:textColor="#3e3a39"  
  15.         android:layout_marginLeft="45dp"  
  16.         />  
  17.     <LinearLayout  
  18.         android:id="@+id/lly_answer"  
  19.         android:layout_width="match_parent"  
  20.         android:layout_height="wrap_content"  
  21.         android:orientation="vertical"  
  22.         android:layout_marginLeft="30dp"  
  23.         android:layout_marginRight="30dp"  
  24.         android:layout_marginTop="10dp"  
  25.           
  26.          android:background="@drawable/shape_dialog_radius_all"  
  27.         >  
  28.           
  29.     </LinearLayout>  
  30.   
  31. </LinearLayout>  

//然后是answer_layout.xml

[java] view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="30dp"  
  5.     android:orientation="vertical"   
  6.    >  
  7.    <LinearLayout   
  8.        android:id="@+id/lly_answer_size"  
  9.        android:layout_width="match_parent"  
  10.        android:layout_height="match_parent"  
  11.        android:orientation="horizontal"  
  12.        >  
  13.        <ImageView   
  14.            android:id="@+id/image"  
  15.            android:layout_width="wrap_content"  
  16.            android:layout_height="wrap_content"  
  17.            android:layout_margin="10dp"/>  
  18.        <TextView   
  19.            android:id="@+id/txt_answer_item"  
  20.            android:layout_width="match_parent"  
  21.            android:layout_height="wrap_content"  
  22.            android:textSize="12sp"  
  23.            android:textColor="#595757"  
  24.            android:layout_gravity="center_vertical"  
  25.            />  
  26.    </LinearLayout>  
  27.     <View  
  28.         android:id="@+id/vw_line"  
  29.         android:layout_width="match_parent"  
  30.         android:layout_height="1dp"  
  31.         android:background="#9EA0A0"  
  32.         >  
  33.           
  34.     </View>  
  35. </LinearLayout>  

然后是主要代码,长久不写博客,有点生疏了,大家顺着思路来看,注释也差不多详尽,如果有不明白的再讨论

[java] view plain copy
  1. public class MainActivity extends Activity {  
  2.     private LinearLayout test_layout;  
  3.     private Page the_page;  
  4.     //答案列表  
  5.     private ArrayList<Answer> the_answer_list;  
  6.     //问题列表  
  7.     private ArrayList<Quesition> the_quesition_list;  
  8.     //问题所在的View  
  9.     private View que_view;  
  10.     //答案所在的View  
  11.     private View ans_view;  
  12.     private LayoutInflater xInflater;  
  13.     private Page page;  
  14.     //下面这两个list是为了实现点击的时候改变图片,因为单选多选时情况不一样,为了方便控制  
  15.     //存每个问题下的imageview  
  16.     private ArrayList<ArrayList<ImageView>> imglist=new ArrayList<ArrayList<ImageView>>();  
  17.     //存每个答案的imageview  
  18.     private ArrayList<ImageView> imglist2;  
  19.     @Override  
  20.     protected void onCreate(Bundle savedInstanceState) {  
  21.         super.onCreate(savedInstanceState);  
  22.         setContentView(R.layout.activity_main);  
  23.         xInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);  
  24.         //假数据  
  25.         initDate();  
  26.         //提交按钮  
  27.         Button button=(Button)findViewById(R.id.submit);  
  28.         button.setOnClickListener(new submitOnClickListener(page));  
  29.     }  
  30.     private void initDate() {  
  31.         //假数据  
  32.         // TODO Auto-generated method stub  
  33.         Answer a_one=new Answer();  
  34.         a_one.setAnswerId("0");  
  35.         a_one.setAnswer_content("男");  
  36.         a_one.setAns_state(0);  
  37.         Answer a_two=new Answer();  
  38.         a_two.setAnswerId("1");  
  39.         a_two.setAnswer_content("女");  
  40.         a_two.setAns_state(0);  
  41.   
  42.         Answer a_three=new Answer();  
  43.         a_three.setAnswerId("3");  
  44.         a_three.setAnswer_content("是");  
  45.         a_three.setAns_state(0);  
  46.         Answer a_four=new Answer();  
  47.         a_four.setAnswerId("4");  
  48.         a_four.setAnswer_content("不是");  
  49.         a_four.setAns_state(0);  
  50.           
  51.           
  52.   
  53.         Answer a_three1=new Answer();  
  54.         a_three1.setAnswerId("3");  
  55.         a_three1.setAnswer_content("是");  
  56.         a_three1.setAns_state(0);  
  57.         Answer a_four1=new Answer();  
  58.         a_four1.setAnswerId("4");  
  59.         a_four1.setAnswer_content("不是");  
  60.         a_four1.setAns_state(0);  
  61.           
  62.         ArrayList<Answer> answers_one=new ArrayList<Answer>();  
  63.         answers_one.add(a_one);  
  64.         answers_one.add(a_two);  
  65.           
  66.           
  67.         ArrayList<Answer> answers_two=new ArrayList<Answer>();  
  68.         answers_two.add(a_one);  
  69.         answers_two.add(a_two);  
  70.         answers_two.add(a_three);  
  71.         answers_two.add(a_four);  
  72.           
  73.         ArrayList<Answer> answers_three=new ArrayList<Answer>();  
  74.         answers_three.add(a_one);  
  75.         answers_three.add(a_two);  
  76.         answers_three.add(a_three);  
  77.         answers_three.add(a_four);  
  78.         answers_three.add(a_three1);  
  79.         answers_three.add(a_four1);  
  80.           
  81.         Quesition q_one=new Quesition();  
  82.         q_one.setQuesitionId("00");  
  83.         q_one.setType("0");  
  84.         q_one.setContent("1、您的性别:");  
  85.         q_one.setAnswers(answers_one);  
  86.         q_one.setQue_state(0);  
  87.           
  88.         Quesition q_two=new Quesition();  
  89.         q_two.setQuesitionId("01");  
  90.         q_two.setType("1");  
  91.         q_two.setContent("2、您是党员吗?");  
  92.         q_two.setAnswers(answers_two);  
  93.         q_two.setQue_state(0);  
  94.           
  95.           
  96.         Quesition q_three=new Quesition();  
  97.         q_three.setQuesitionId("03");  
  98.         q_three.setType("1");  
  99.         q_three.setContent("3、您是dsfsdfsd吗?");  
  100.         q_three.setAnswers(answers_three);  
  101.         q_three.setQue_state(0);  
  102.           
  103.         ArrayList<Quesition> quesitions=new ArrayList<Quesition>();  
  104.         quesitions.add(q_one);  
  105.         quesitions.add(q_two);  
  106.         quesitions.add(q_three);  
  107.           
  108.         page=new Page();  
  109.         page.setPageId("000");  
  110.         page.setStatus("0");  
  111.         page.setTitle("第一次调查问卷");  
  112.         page.setQuesitions(quesitions);  
  113.         //加载布局  
  114.         initView(page);  
  115.     }  
  116.     private void initView(Page page) {  
  117.         // TODO Auto-generated method stub    
  118.         //这是要把问题的动态布局加入的布局  
  119.         test_layout=(LinearLayout)findViewById(R.id.lly_test);  
  120.         TextView page_txt=(TextView)findViewById(R.id.txt_title);  
  121.         page_txt.setText(page.getTitle());  
  122.         //获得问题即第二层的数据  
  123.         the_quesition_list=page.getQuesitions();  
  124.         //根据第二层问题的多少,来动态加载布局  
  125.         for(int i=0;i<the_quesition_list.size();i++){  
  126.             que_view=xInflater.inflate(R.layout.quesition_layout, null);  
  127.             TextView txt_que=(TextView)que_view.findViewById(R.id.txt_question_item);  
  128.             //这是第三层布局要加入的地方  
  129.             LinearLayout add_layout=(LinearLayout)que_view.findViewById(R.id.lly_answer);  
  130.             //判断单选-多选来实现后面是*号还是*多选,  
  131.             if(the_quesition_list.get(i).getType().equals("1")){  
  132.                 set(txt_que,the_quesition_list.get(i).getContent(),1);  
  133.             }else{  
  134.                 set(txt_que,the_quesition_list.get(i).getContent(),0);  
  135.             }  
  136.             //获得答案即第三层数据  
  137.             the_answer_list=the_quesition_list.get(i).getAnswers();  
  138.             imglist2=new ArrayList<ImageView>();  
  139.             for(int j=0;j<the_answer_list.size();j++){  
  140.                 ans_view=xInflater.inflate(R.layout.answer_layout, null);  
  141.                 TextView txt_ans=(TextView)ans_view.findViewById(R.id.txt_answer_item);  
  142.                 ImageView image=(ImageView)ans_view.findViewById(R.id.image);  
  143.                 View line_view=ans_view.findViewById(R.id.vw_line);  
  144.                 if(j==the_answer_list.size()-1){  
  145.                     //最后一条答案下面不要线是指布局的问题  
  146.                     line_view.setVisibility(View.GONE);  
  147.                 }  
  148.                 //判断单选多选加载不同选项图片  
  149.                 if(the_quesition_list.get(i).getType().equals("1")){  
  150.                     image.setBackgroundDrawable(getResources().getDrawable(R.drawable.multiselect_false));  
  151.                 }else{  
  152.                     image.setBackgroundDrawable(getResources().getDrawable(R.drawable.radio_false));  
  153.                 }  
  154.                 Log.e("---""------"+image);  
  155.                 imglist2.add(image);  
  156.                 txt_ans.setText(the_answer_list.get(j).getAnswer_content());  
  157.                 LinearLayout lly_answer_size=(LinearLayout)ans_view.findViewById(R.id.lly_answer_size);  
  158.                 lly_answer_size.setOnClickListener(new answerItemOnClickListener(i,j,the_answer_list,txt_ans));  
  159.                 add_layout.addView(ans_view);  
  160.             }  
  161.             /*for(int r=0; r<imglist2.size();r++){ 
  162.                 Log.e("---", "imglist2--------"+imglist2.get(r)); 
  163.             }*/  
  164.               
  165.             imglist.add(imglist2);  
  166.               
  167.             test_layout.addView(que_view);  
  168.         }  
  169.         /*for(int q=0;q<imglist.size();q++){ 
  170.             for(int w=0;w<imglist.get(q).size();w++){ 
  171.                 Log.e("---", "共有------"+imglist.get(q).get(w)); 
  172.             } 
  173.         }*/  
  174.                   
  175.     }  
  176.     private void set(TextView tv_test, String content,int type) {  
  177.         //为了加载问题后面的* 和*多选  
  178.         // TODO Auto-generated method stub  
  179.         String w;  
  180.         if(type==1){  
  181.              w = content+"*[多选题]";  
  182.         }else{  
  183.              w = content+"*";  
  184.         }  
  185.           
  186.         int start = content.length();  
  187.         int end = w.length();  
  188.         Spannable word = new SpannableString(w);  
  189.         word.setSpan(new AbsoluteSizeSpan(25), start, end,  
  190.                 Spannable.SPAN_INCLUSIVE_INCLUSIVE);  
  191.         word.setSpan(new StyleSpan(Typeface.BOLD), start, end,  
  192.                 Spannable.SPAN_INCLUSIVE_INCLUSIVE);  
  193.         word.setSpan(new ForegroundColorSpan(Color.RED), start, end,  
  194.                 Spannable.SPAN_INCLUSIVE_INCLUSIVE);  
  195.         tv_test.setText(word);  
  196.     }  
  197.     class answerItemOnClickListener implements OnClickListener{  
  198.         private int i;  
  199.         private int j;  
  200.         private TextView txt;  
  201.         private ArrayList<Answer> the_answer_lists;  
  202.         public answerItemOnClickListener(int i,int j, ArrayList<Answer> the_answer_list,TextView text){  
  203.             this.i=i;  
  204.             this.j=j;  
  205.             this.the_answer_lists=the_answer_list;  
  206.             this.txt=text;  
  207.               
  208.         }  
  209.         //实现点击选项后改变选中状态以及对应图片  
  210.         @Override  
  211.         public void onClick(View arg0) {  
  212.             // TODO Auto-generated method stub  
  213.             //判断当前问题是单选还是多选  
  214.             /*Log.e("------", "选择了-----第"+i+"题"); 
  215.             for(int q=0;q<imglist.size();q++){ 
  216.                 for(int w=0;w<imglist.get(q).size();w++){ 
  217. //                  Log.e("---", "共有------"+imglist.get(q).get(w)); 
  218.                 } 
  219.             } 
  220.             Log.e("----", "点击了---"+imglist.get(i).get(j));*/  
  221.               
  222.             if(the_quesition_list.get(i).getType().equals("1")){      
  223.                 //多选  
  224.                 if(the_answer_lists.get(j).getAns_state()==0){  
  225.                     //如果未被选中  
  226.                     txt.setTextColor(Color.parseColor("#EA5514"));  
  227.                     imglist.get(i).get(j).setBackgroundDrawable(getResources().getDrawable(R.drawable.multiselect_true));  
  228.                     the_answer_lists.get(j).setAns_state(1);  
  229.                     the_quesition_list.get(i).setQue_state(1);  
  230.                 }else{  
  231.                     txt.setTextColor(Color.parseColor("#595757"));  
  232.                     imglist.get(i).get(j).setBackgroundDrawable(getResources().getDrawable(R.drawable.multiselect_false));  
  233.                     the_answer_lists.get(j).setAns_state(0);  
  234.                     the_quesition_list.get(i).setQue_state(1);  
  235.                 }  
  236.             }else{  
  237.                 //单选  
  238.                   
  239.                 for(int z=0;z<the_answer_lists.size();z++){  
  240.                     the_answer_lists.get(z).setAns_state(0);  
  241.                     imglist.get(i).get(z).setBackgroundDrawable(getResources().getDrawable(R.drawable.radio_false));  
  242.                 }  
  243.                 if(the_answer_lists.get(j).getAns_state()==0){  
  244.                     //如果当前未被选中  
  245.                     imglist.get(i).get(j).setBackgroundDrawable(getResources().getDrawable(R.drawable.radio_true));  
  246.                     the_answer_lists.get(j).setAns_state(1);  
  247.                     the_quesition_list.get(i).setQue_state(1);  
  248.                 }else{  
  249.                     //如果当前已被选中  
  250.                     the_answer_lists.get(j).setAns_state(1);  
  251.                     the_quesition_list.get(i).setQue_state(1);  
  252.                 }  
  253.                   
  254.             }  
  255.             //判断当前选项是否选中  
  256.               
  257.               
  258.               
  259.         }  
  260.           
  261.     }  
  262.     class submitOnClickListener implements OnClickListener{  
  263.         private Page page;  
  264.         public submitOnClickListener(Page page){  
  265.             this.page=page;  
  266.         }  
  267.         @Override  
  268.         public void onClick(View arg0) {  
  269.             // TODO Auto-generated method stub  
  270.             //判断是否答完题  
  271.             boolean isState=true;  
  272.             //最终要的json数组  
  273.             JSONArray jsonArray = new JSONArray();  
  274.             //点击提交的时候,先判断状态,如果有未答完的就提示,如果没有再把每条答案提交(包含问卷ID 问题ID 及答案ID)  
  275.             //注:不用管是否是一个问题的答案,就以答案的个数为准来提交上述格式的数据  
  276.             for(int i=0;i<the_quesition_list.size();i++){  
  277.                 the_answer_list=the_quesition_list.get(i).getAnswers();  
  278.                 //判断是否有题没答完  
  279.                 if(the_quesition_list.get(i).getQue_state()==0){  
  280.                     Toast.makeText(getApplicationContext(), "您第"+(i+1)+"题没有答完", Toast.LENGTH_LONG).show();  
  281.                     jsonArray=null;  
  282.                     isState=false;  
  283.                     break;  
  284.                 }else{  
  285.                     for(int j=0;j<the_answer_list.size();j++){  
  286.                         if(the_answer_list.get(j).getAns_state()==1){  
  287.                             JSONObject json = new JSONObject();  
  288.                             try {  
  289.                                 json.put("psychologicalId", page.getPageId());  
  290.                                 json.put("questionId", the_quesition_list.get(i).getQuesitionId());  
  291.                                 json.put("optionId", the_answer_list.get(j).getAnswerId());  
  292.                                 jsonArray.put(json);  
  293.                             } catch (JSONException e) {  
  294.                                 // TODO Auto-generated catch block  
  295.                                 e.printStackTrace();  
  296.                             }  
  297.                         }  
  298.                     }  
  299.                 }  
  300.                   
  301.             }  
  302.             if(isState){  
  303.                 if(jsonArray.length()>0){  
  304.                     Log.e("af", jsonArray.toString());  
  305.                       for(int item=0;item<jsonArray.length();item++){  
  306.                         JSONObject job;  
  307.                         try {  
  308.                             job = jsonArray.getJSONObject(item);  
  309.                              Log.e("----""pageId--------"+job.get("pageId"));  
  310.                              Log.e("----""quesitionId--------"+job.get("quesitionId"));  
  311.                              Log.e("----""answerId--------"+job.get("answerId"));       
  312.                         } catch (JSONException e) {  
  313.                             // TODO Auto-generated catch block  
  314.                             e.printStackTrace();  
  315.                         }  // 遍历 jsonarray 数组,把每一个对象转成 json 对象  
  316.                                     
  317.                       }           
  318.                   
  319.                     }  
  320.               
  321.             }  
  322.           
  323.         }  
  324.     }  
  325.       
  326. }  

人不能懒惰啊,以后要多多总结,欢迎大家讨论。