本人没脑子
2021-05-14 15:26
采纳率: 100%
浏览 104

Android Studio代码下面总是出现一条白线,是为什么呀?

总是敲着敲着就出现一条白线,不知道是什么原因

 

代码如下: 

package com.xishixuexigongshe.utils;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.renderscript.ScriptGroup;
import android.util.Xml;

import com.xishixuexigongshe.bean.ExerciseBean;

import org.xmlpull.v1.XmlPullParser;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

public class AnalysisUtils {
    /**
     * 从sharedPreference中读取用户名
     * @param context
     * @return
     */
    public  static String readLoginUserName(Context context){
        SharedPreferences sp = context.getSharedPreferences("loginInfo",Context.MODE_PRIVATE);
        String userName = sp .getString("LoginUserName","");
        return userName;
    }
    /**
     * 解析每章习题
     */
    public static List<ExerciseBean> getExercisesInfos(InputStream is) throws Exception{
        XmlPullParser parser = Xml.newPullParser();
        List<ExerciseBean> exercisesInfos = null;
        ExerciseBean exercisesInfo = null;
        int type = parser.getEventType();
        while (type != XmlPullParser.END_DOCUMENT){
            switch (type){
                case XmlPullParser.START_TAG:
                if ("infos".equals(parser.getName())){
                    exercisesInfos = new ArrayList<ExerciseBean>();
                }else if ("exercises".equals(parser.getName())){
                    exercisesInfo = new ExerciseBean();
                    String ids = parser.getAttributeValue(0);
                    exercisesInfo.subjectId = Integer.parseInt(ids);
                }else if ("subject".equals(parser.getName())){
                    String subject = parser.nextText();
                    exercisesInfo.subject = subject;
                }else if("a".equals(parser.getName())){
                    String a = parser.nextText();
                    exercisesInfo.a = a;
                }else if("b".equals(parser.getName())){
                    String b = parser.nextText();
                    exercisesInfo.b = b;
                }else if("c".equals(parser.getName())){
                    String c = parser.nextText();
                    exercisesInfo.c = c;
                }else if("d".equals(parser.getName())){
                    String d = parser.nextText();
                    exercisesInfo.d = d;
                }else if("answer".equals(parser.getName())){
                    String answer = parser.nextText();
                    exercisesInfo.answer = Integer.parseInt(answer);
                }
                break;
                case XmlPullParser.END_TAG:
                    if ("exercises".equals(parser.getName())){
                        exercisesInfos.add(exercisesInfo);
                        exercisesInfo = null;
                    }
                    break;
            }
            type = parser.next();
        }
        return exercisesInfos;
    }
}

求求各位好心人救救孩子吧

 

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • usecf 2021-05-14 16:10
    已采纳

    会不会是你敲代码 有智能提示功能,没有找到对应的属性或者方法

    点赞 评论
  • 本人没脑子 2021-05-25 15:42

    那请问您知道怎么解决吗?我不太懂…

    点赞 评论

相关推荐 更多相似问题